10000 [i18n] Request for internationalization (locales) · Issue #4168 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[i18n] Request for internationalization (locales) #4168

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

Open
colinhacks opened this issue Apr 15, 2025 · 31 comments
Open

[i18n] Request for internationalization (locales) #4168

colinhacks opened this issue Apr 15, 2025 · 31 comments

Comments

@colinhacks
Copy link
Owner
colinhacks commented Apr 15, 2025

Zod 4 has a more mature system for internationalizaton. Here is an example of loading the Spanish locale:

import * as z from "zod";

z.config(z.locales.es());

const result = z.string().safeParse(123);
result.error!.issues[0].message;
// => Entrada inválida: se esperaba string, recibido número

I'm putting out an open call for locales to the Zod ecosystem. I think a human touch is important to make error messages friendly and useful.

Instructions

Refer to this pull request for an example of creating a locale: https://github.com/colinhacks/zod/pull/4158/files

That PR doesn't update the Nouns map, but you should (to the best of your ability). Didn't realize this before linking it as an example here.

To summarize:

1 Create a new file under packages/core/src/locales/<code>.ts

Use the language code for your language. Dialects (pt-BR) are also encouraged.

Using the English locale as a starting point, translate all error messages: https://github.com/colinhacks/zod/blob/v4/packages/core/src/locales/en.ts

2 Export your dialect from packages/core/locales.ts

// other languages...
import zz from "./locales/zz.js";

export { 
  // ... other languages
  zz
};

3 Add to docs

Add your new language variant to the Error customization page under the "Locales" section. Keep the list in alphabetical order.

4 Submit the PR

Once you submit a PR, add a comment below so others can quickly see which languages are already covered.


Thank you for your help on this!

@helmerdx
Copy link
Contributor
helmerdx commented Apr 16, 2025

Adding portuguese + fix spanish

#4171

@helmerdx
Copy link
8000 Contributor

Adding french

#4172

@Christopher96u
Copy link

This looks good. I'm fluent in Spanish, I'll have a look, but the locales shouldn't live in a separate package? Maybe I'm wrong but it looks like we're increasing the bundle size

@Abdalrhman-Almarakeby
Copy link
Contributor

Added Arabic #4176.

@yoshimatsu567
Copy link
Contributor

Added Japanese #4170 .

@TheOnlyTails
Copy link
Contributor

Added Hebrew #4183.

@szarbartosz
Copy link
Contributor

Added Polish #4184

@MrBarracuda
Copy link
Contributor

Added Ukrainian #4185

@Levminer
Copy link
Contributor

Added Hungarian #4186

@Heenkkk
Copy link
Contributor
Heenkkk commented Apr 16, 2025

Added Finnish #4188

Edit: Will still be making a few tweaks to make it feel a bit more natural.

Edit 2: Wondering what the policy regarding translating JS data types should actually be. Translating only a few feels weird as you're now mixing languages, but making an exhaustive list of translations is quite difficult with all the different possible cases.

@GrahamQuan
Copy link
Contributor

Add Simplified Chinese #4189

@hoangtrung99
Copy link
Contributor
hoangtrung99 commented Apr 16, 2025

@colinhacks
Hi sir, I have created a PR to add Vietnamese 🇻‍🇳 🇻‍🇳 🇻‍🇳 , please check it.
#4191

@filipditrich
Copy link
Contributor

Added Czech language in #4192. Hope it helps!

@krisnaw
Copy link
Contributor
krisnaw commented Apr 16, 2025

Added Bahasa Indonesia #4195

@berz8
Copy link
Contributor
berz8 commented Apr 16, 2025

Added italian #4194

@VladSez
Copy link
Contributor
VladSez commented Apr 16, 2025

Added Russian #4197

@VladSez
Copy link
Contributor
VladSez commented Apr 16, 2025

Added Belarusian #4199

@kadimelifba
Copy link
Contributor

Added Ottoman Turkish #4200

@hAbuMustafa
Copy link
Contributor
hAbuMustafa commented Apr 16, 2025

Added Arabic #4176.

My apologies I didn't notice you already worked on it.
I did my own version (#4203 ) if you don't mind checking it out, and we can discuss the best way to implement the localization in the most natural-like way.

@kyziq
Copy link
Contributor
kyziq commented Apr 17, 2025

Added Malay #4204

@Geuni620
Copy link
Contributor

Added Korean #4205

@Mojtaba-NA
Copy link
Contributor

Added Farsi(persian) #4207

@Abdalrhman-Almarakeby
Copy link
Contributor

Added Arabic #4176.

My apologies I didn't notice you already worked on it. I did my own version (#4203 ) if you don't mind checking it out, and we can discuss the best way to implement the localization in the most natural-like way.

No problem, thank you for your help! Your version has a great natural translation. Could you take a look at my PR (#4176) and leave comments with any changes you'd suggest? That way, we can discuss them, and you can be a collaborator on this PR.

@antonio-ivanovski
Copy link
Contributor

Added Macedonian 🇲‍🇰 #4214

@neighborhood999
Copy link
Contributor

Added Traditional Chinese 🇹🇼🧋 #4226

@mskutle
Copy link
Contributor
mskutle commented Apr 18, 2025

Added Norwegian 🇳🇴 #4229

@mildronize
Copy link
Contributor

Added Thai 🇹🇭 #4230

@sasivarnan
Copy link
Contributor

Added Tamil #4237

@pmontp19
Copy link
Contributor

Adding Catalan #4287

@mthomas-io
Copy link

Adds Dutch (NL): #4425

@SuuSoJeat
Copy link
SuuSoJeat commented May 20, 2025

Added Khmer (KH) 🇰‍🇭 : #4447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0