-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Languages: add Finnish language #4188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
3b34b7e
a5c620f
430a17c
a2c80a9
aea0e95
ae8622a
9e742ba
7446f2a
a7cf5a8
aeceac4
0dfe87e
8709eb9
c0271f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import az from "./locales/az.js"; | ||
| import en from "./locales/en.js"; | ||
| import es from "./locales/es.js"; | ||
| import fi from "./locales/fi.js"; | ||
|
|
||
| export { az, es, en }; | ||
| export { az, es, en, fi }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,197 @@ | ||||||
| import type { $ZodStringFormats } from "../checks.js"; | ||||||
| import type * as errors from "../errors.js"; | ||||||
| import type { $ZodTypeDef } from "../schemas.js"; | ||||||
| import * as util from "../util.js"; | ||||||
|
|
||||||
| const Sizable: Record<string, { unit: string; subject: string }> = { | ||||||
| string: { unit: "merkkiä", subject: "merkkijonon" }, | ||||||
| file: { unit: "tavua", subject: "tiedoston" }, | ||||||
| array: { unit: "alkiota", subject: "listan" }, | ||||||
| set: { unit: "alkiota", subject: "joukon" }, | ||||||
| number: { unit: "", subject: "luvun" }, | ||||||
| bigint: { unit: "", subject: "suuren kokonaisluvun" }, | ||||||
| int: { unit: "", subject: "kokonaisluvun" }, | ||||||
| date: { unit: "", subject: "päivämäärän" }, | ||||||
| }; | ||||||
|
|
||||||
| function getSizing(origin: string): { unit: string; subject: string } | null { | ||||||
| return Sizable[origin] ?? null; | ||||||
| } | ||||||
|
|
||||||
| const TypeNames: { [k in $ZodTypeDef["type"] | (string & {})]?: string } = { | ||||||
| string: "merkkijono", | ||||||
| number: "luku", | ||||||
| boolean: "totuusarvo", | ||||||
| bigint: "suuri kokonaisluku", | ||||||
| symbol: "symboli", | ||||||
| null: "tyhjä", | ||||||
| undefined: "määrittelemätön", | ||||||
| date: "päivämäärä", | ||||||
| object: "objekti", | ||||||
| file: "tiedosto", | ||||||
| array: "lista", | ||||||
| map: "hakemisto", | ||||||
|
||||||
| set: "joukko", | ||||||
| nan: "epäluku", | ||||||
| promise: "lupaus", | ||||||
| }; | ||||||
|
|
||||||
| function getTypeName(type: string): string { | ||||||
| return TypeNames[type] ?? type; | ||||||
| } | ||||||
|
|
||||||
| export const parsedType = (data: any): string => { | ||||||
| const t = typeof data; | ||||||
|
|
||||||
| switch (t) { | ||||||
| case "number": { | ||||||
| return Number.isNaN(data) ? "epäluku" : "luku"; | ||||||
| } | ||||||
| case "bigint": { | ||||||
| return Number.isNaN(data) ? "epäluku" : "suuri kokonaisluku"; | ||||||
| } | ||||||
| case "boolean": { | ||||||
| return "totuusarvo"; | ||||||
|
||||||
| return "totuusarvo"; | |
| return TypeNames["boolean"]; |
With the current pattern here, if any of these needs terms tweaking later in the future you would need to remember to update same string into two places.
edit: or you seem to have some sort of getter for this already defined in getTypeName
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, this is pretty tricky.
I might prefer this to be "Promise" actually... Idk.
Heenkkk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, I feel temptation to translate map to "tietueessa" – "hakemistossa" just instantly gives me idea about a file system hierarchy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Viitaten vähän samaan tuon datatyyppien poisheivaamisen kanssa, niin tässäkin voisi melkeen yleistää nuo invalid_element ja invalid_key -tilanteet niin, että niissä sanotaan aina jotain tyyliin:
Virheellinen arvo joukossa
ja
Virheellinen avain tietueessa
Sillä itse datatyypillä ei varmaan tuossa kontekstissa ole kuitenkaan ihan hirveän oleellista tehtävää
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pallottelen vaihtoehtoisella sanamuodolla
| return `Virheellinen tyyppi: täytyy olla ${getTypeName(issue.expected)}, oli ${parsedType(issue.input)}`; | |
| return `Virheellinen tyyppi: odotettiin ${getTypeName(issue.expected)}, oli ${parsedType(issue.input)}`; |
Joka tapauksessa tämä "täytyy olla" IMO huomattavasti parempi kuin alkuperäinen "pitäisi olla" 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to also be some older fi.json in
aiji42//zod-i18n library which has same error translated as:
"Odotettiin arvon olevan {{expected}}, saatiin {{received}}"
But yeah, not sure, food for thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh harkitsen vahvasti sitä, että heivais kuitenkin nää datatyyppien käännökset kokonaan pois tästä kohtaa, kun näitä JS datatyyppejä on niin mahdotonta saada mielekkäästi ja tyhjentävästi hoidettua. Voisi vaan olla esim tuo:
"Virheellinen tyyppi: odotettiin {{issue.expected}}, saatiin {{parsedType(issue.input)}}"
jossa tuo parsedType vaan palauttaa saman kuin tuo englanninkielinen versio.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of hate this term, especially if these are displayed to non-technical users.
But I am not entirely sure where to draw the line. Similar to
mapcomment below, I think in this case"tietue"might also work...