Dev.to WebDev 🛠 Dev 👁 2 📖 3 min read

9 translation-file bugs that pass code review (and how to catch them automatically)

Translation files are easy to break and hard to review. A diff of fr.json is a wall of strings in a language most reviewers don't read, so the bugs below get approved every day. None of them throw at build time. They sho

Translation files are easy to break and hard to review. A diff of fr.json is a wall of strings in a language most reviewers don't read, so the bugs below get approved every day. None of them throw at build time. They show up as a blank button, a raw {name} on screen, or a crash in one locale only.

Here are the nine I see most, with a small example of each.

1. Missing keys

// en.json
{ "checkout": { "pay": "Pay now", "cancel": "Cancel" } }

// fr.json
{ "checkout": { "pay": "Payer maintenant" } }

Depending on your library, French users see checkout.cancel, an English fallback, or nothing at all.

2. Renamed placeholders

// en.json
{ "greet": "Hello, {name}!" }
// fr.json
{ "greet": "Bonjour, {nom} !" }

Someone (or a machine translator) "translated" the variable name. The app now prints Bonjour, {nom} ! literally.

3. Printf arguments that no longer match

en: "%1$s invited %2$s"
de: "%2$s wurde von %s eingeladen"

Mixing positional and non-positional arguments, or dropping one, is a crash on Android and garbage text elsewhere.

4. ICU plurals without other

{count, plural, one {# file} few {# soubory}}

other is required. Many runtimes throw when the count falls outside the listed categories.

5. Unbalanced braces

"{count, plural, one {# item} other {# items}"

One missing } and the whole message fails to parse, often only at runtime and only in that locale.

6. Empty values

{ "footer": "" }

Usually a translator skipped it. It renders as an empty element and nobody notices for weeks.

7. Untranslated copies

// es.json
{ "save": "Save" }

Identical to the base text. Sometimes that's intended (brand names, "OK"), often it's a forgotten string.

8. Leading or trailing whitespace differences

// en.json  "pad": "Total:"
// ja.json  "pad": "合計: "

Harmless until it isn't: double spaces, broken alignment, or a test that compares strings exactly.

9. Latin punctuation inside right-to-left text

In Arabic text, an ASCII ? or , instead of ؟ or ، looks wrong to native readers and can jump to the wrong side when mixed with numbers or Latin words.

Catching them automatically

All nine are mechanical, so a machine should find them, not your reviewer. The check is simple in principle: take the base locale as the source of truth, then for every other locale compare the key set, the placeholder set of each string (including ICU argument names inside nested plural/select branches) and the message syntax.

You can write that yourself in an afternoon for one format. I needed it for JSON, Flutter ARB, gettext PO, Android strings.xml, iOS .strings and Rails YAML, so I built two tools. Disclosure: I'm the developer of both.

In CI (free, all formats, any number of locales): a GitHub Action that fails the build on errors.

- uses: actions/checkout@v4
- uses: raiden-171/localeguard-action@v1
  with:
    path: src/locales
    base-locale: en
    fail-on: error

https://github.com/Raiden-171/localeguard-action

In the editor: LocaleGuard for VS Code (also VSCodium, Cursor and Windsurf via Open VSX) shows the same problems in the Problems panel as you type. It is read-only and file contents never leave your machine.

  • Free: JSON and ARB, up to 3 locales per workspace.
  • Pro (USD 12 one time): PO, Android, iOS and YAML, unlimited locales, a Markdown report, and a quick-fix that inserts missing keys marked TODO:.

https://marketplace.visualstudio.com/items?itemName=raiden-171.localeguard

Whatever you use, put some check in CI. Translation bugs are cheap to catch before merge and embarrassing after release.

Which of these has bitten you? And is there a tenth I should add to the check?

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.