DEV Community

Cover image for The translation bugs code review keeps missing
Mohamed Almarag
Mohamed Almarag

Posted on AI-assisted

The translation bugs code review keeps missing

In Dashy's Hindi translation, someone translated a variable name. The message said {थीम} instead of {theme}.

The JSON was valid and the diff looked fine. But vue-i18n could not compile the message. In Hindi, clicking Save in the theme editor stored the colors and then threw an error, so no confirmation appeared and the editor stayed open.

I found the same kind of bug in two other projects:

  • Open WebUI: placeholder names translated in 10 locales.
  • listmonk: five Arabic messages lost their {name}. Deleting a campaign said only "deleted", without the campaign name.

All three fixes were merged by the maintainers within a day.

Why review misses them

The reviewer usually can't read Hindi or Arabic. The file is valid JSON, so nothing fails. The bug shows up only when a user opens that screen in that language.

Plural forms are worse. Arabic has six of them: zero, one, two, few, many and other. Most projects write two, because English has two.

What I built

Locale Guard is a GitHub Action that runs on every pull request. It reads the locale files with each library's own message parser, compares every language with the base one, and writes one comment with:

  • missing keys, with a block ready to paste into each file
  • placeholders, ICU arguments and tags that differ from the base message
  • messages that don't compile
  • plural forms each language needs, from Intl.PluralRules
  • text that was never translated

It works with vue-i18n (and Nuxt), next-intl, react-intl, i18next and Rails locale files.

Old projects

Most projects already have hundreds of these issues, so a check that fails on all of them gets turned off in a week.

Locale Guard runs the same checks on the base branch and fails only on what the pull request adds. Old issues are counted and collapsed. On Directus, with 70 languages and about 104,000 existing issues, a pull request is still judged only on what it changes.

Setup

name: Translations

on: pull_request

permissions:
  contents: read
  pull-requests: write

jobs:
  locale-guard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: Mohamed-Almarag/locale-guard@v1
        with:
          files: locales/{locale}.json
          format: vue-i18n
Enter fullscreen mode Exit fullscreen mode

If you try it and it reports something that isn't a bug, please open an issue. False positives are the first thing I want to fix.

I wrote this post with help from an AI assistant, and checked every detail against the merged pull requests.

Top comments (0)