Docs / Translate / Flutter ARB
Translate Flutter ARB files
Translate lib/l10n/app_en.arb into app_<lang>.arb for Flutter’s gen-l10n, with {placeholders}, ICU plural and select messages, and @key descriptions used as context.
How it works
localize-dev translate reads your template ARB file, sends each message’s @key description with it as context, and writes app_ar.arb, app_pt_BR.arb and the rest with @@locale set. gen-l10n picks the new files up and adds the languages to supportedLocales on the next build.
ICU plural and select messages are split into their branches, translated, and put back together with the forms the language needs. Exact matches like =0 stay, and the message is parsed before it’s written.
Before and after
Real output of localize-dev translate --locales ar on the first file. Arabic uses six plural forms, so the itemCount plural gets zero, one, two, few, many and other next to its =0 branch.
{
"@@locale": "en",
"cartTitle": "Your cart",
"@cartTitle": { "description": "Title of the shopping cart screen" },
"greeting": "Hi {name}, ready to check out?",
"@greeting": { "placeholders": { "name": { "type": "String" } } },
"itemCount": "{count, plural, =0{Your cart is empty} =1{1 item} other{{count} items}}",
"@itemCount": { "placeholders": { "count": { "type": "int" } } }
}{
"@@locale": "ar",
"cartTitle": "عربتك",
"greeting": "مرحباً {name}، هل أنت مستعد للدفع؟",
"itemCount": "{count, plural, =0 {عربتك فارغة} zero {0 عناصر} one {عنصر واحد} two {عنصران} few {{count} عناصر} many {{count} عناصر} other {{count} عناصر}}"
}What stays intact
{name}placeholders, checked- ICU plurals with every CLDR form the language uses
- Exact
=0and=1branches and select branches - The underscore file names gen-l10n expects (
app_pt_BR.arb)
Common mistakes, and how they’re avoided
Only one and other in every language
Arabic has six plural forms and Polish four. A translated other alone makes counts like 2 or 5 read wrong. The forms each language uses are written for every plural.
A missing brace
One unmatched } in an ICU message stops flutter gen-l10n. Every translated message is parsed before it’s written; one that doesn’t parse is retried, then left out and reported.
No context for short strings
“Book” can be a noun or a verb. Add a description under @book in the template and it’s sent with the message, so the translation fits the screen it’s on.
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.