Translate JSON locale files
Fill in missing translations in i18next, react-intl, vue-i18n, ngx-translate and Transloco JSON files, with placeholders, ICU messages and every plural form each language needs.
How it works
localize-dev translate reads the JSON file in your source language, finds the keys each other language is missing and writes them in, in the source file’s key order so the files diff cleanly. Translations you already have aren’t touched.
It knows each library’s conventions: i18next {{name}}, $t(key) nesting and _one / _other plural suffixes, react-intl and next-intl ICU messages, vue-i18n | plurals, @:key links and {'@'} literals, and Laravel :name.
Before and after
Real output of localize-dev translate --locales pl on the first file. English has two plural forms. Polish has four, so _few and _many are added.
{
"inbox": {
"title": "Inbox",
"welcome": "Welcome back, {{name}}",
"unread_one": "{{count}} unread message",
"unread_other": "{{count}} unread messages",
"empty": "Nothing here yet. <1>Write a message</1>"
}
}{
"inbox": {
"title": "Skrzynka odbiorcza",
"welcome": "Witaj ponownie, {{name}}",
"unread_one": "{{count}} nieprzeczytana wiadomość",
"unread_few": "{{count}} nieprzeczytane wiadomości",
"unread_many": "{{count}} nieprzeczytanych wiadomości",
"unread_other": "{{count}} nieprzeczytanych wiadomości",
"empty": "Nic tu jeszcze nie ma. <1>Napisz wiadomość</1>"
}
}What stays intact
- Placeholders, checked: a translation that adds, drops or renames one is rejected
- Markup like
<1>…</1>for<Trans> - Every plural form the language uses:
_fewand_manyin Polish, six forms in Arabic - The source file’s key order and indentation
Common mistakes, and how they’re avoided
Copying only _one and _other
English needs two plural forms, so a file with _one and _other looks complete. Polish, Russian and Arabic need more, and i18next quietly falls back to _other. Every form the target language uses is written, and a plural only counts as translated once all of them are there.
Placeholders that get translated
Asked to translate Welcome back, {{name}}, a model sometimes translates name too. Placeholders are masked before translation and checked after. A translation that changes them is retried, then left out and reported, never written.
Plurals inside a longer sentence
An ICU plural or select nested inside other text can’t be split apart safely. Top-level plurals and selects are translated branch by branch; nested ones are reported so you can translate them by hand.
Run it
In the folder that holds your locale files. Languages without a file yet get one. --dry-run shows what would change first.
npx localize-dev login
# Preview, then write the missing translations
npx localize-dev translate --dry-run -l es,fr,de
npx localize-dev translate -l es,fr,deThen keep it complete in CI. This needs no API key and fails when a language is missing translations:
npx localize-dev check --only translationsFree for 1,000 strings a month. A string counts once however many languages it goes into. Create a free account
Guides for apps that use this format
When the copy is still hardcoded in your code, localize-dev run moves it into this format first.