Convert .arb to JSON
Flutter's Application Resource Bundle on one side, plain i18n JSON on the other, for when the same product ships as an app and a website.
Runs in your browser. The file never leaves your browser.
ARB is JSON with one rule
An .arb file is JSON where any key starting with @ is metadata about the key of the same name without it, and @@locale is metadata about the file. That single rule is why a straight JSON.parse gives you a file with twice as many keys as it should have, half of them objects. This tool separates the two: the strings become the JSON, and @key.description becomes the translator comment where the target format has room for one.
Converting is easy. Not breaking the file is the hard part.
Every converter that treats a language file as plain text will eventually ship you a crash. These are the three places it happens.
- Placeholders stay placeholders
- %@, %lld, %1$s, {name} and {{count}} come out exactly as they went in. A placeholder that got escaped, renumbered or translated is a crash on the device, not a typo.
- Plural forms stay separate
- Xcode variations, the Android plurals element and gettext msgstr[n] all mean the same thing and all spell it differently. They map onto each other here. Polish has four forms; all four survive.
- Keys keep their shape
- Nesting, dotted paths, arrays and translator comments carry across wherever the target format has somewhere to put them. Where it does not, the section below says so.
What does not come across
Written down here, because the alternative is finding out in a broken build.
Placeholder declarations do not survive. A block declaring that count is an int formatted as compact carries type information the intermediate form has no field for, and a guessed type is worse than a missing one: flutter gen-l10n would generate a wrongly typed method signature from it. ICU plural syntax inside the value itself, {count, plural, one {…} other {…}}, is passed through untouched, because for ARB that is ordinary text.
How it works
Drop the file in
Drag your .arb onto the left box, pick it with the file button, or paste the text. Nothing leaves this tab. The conversion runs here.
Read the result
The JSON appears as you type. The counter under the box says how many keys came through, so a file that lost half its content is visible immediately.
Copy or download
Take the text to the clipboard, or download it with the right extension. Swap the arrow to go the other way.
Questions
- Do ICU plurals inside the string survive?
- Yes, verbatim. In ARB, plurals live inside the value as ICU syntax, {count, plural, one {…} other {…}}, rather than in a separate structure, so the converter treats them as text and does not touch a brace.
- What about @@locale?
- It is read as file metadata and not turned into a translatable key. Converting back, an @@locale is written for the language you are targeting.
- Can I go JSON to .arb for a new Flutter app?
- Yes, swap the direction. You get valid ARB with @@locale and a description block for every key that carried a comment. You will still want to add placeholders declarations by hand for any string with typed arguments.
- Does it handle a .arb with 3,000 keys?
- Yes. Everything runs locally, so the only limit is the RAM of your browser, not a transfer size or a rate limit.
Other converters
One language file in, many languages out.
Converting a format is something you can do by hand. Translating a whole file without breaking a single placeholder is what shipglobal does. On the next release it translates only what changed.