How to check locale files for errors

Have you ever wondered why a translated string isn’t used by Discourse? Is Discourse showing wrong numbers and dates when a locale other than English is used? Are you seeing “Invalid Format” errors in some parts of Discourse?

It’s quite likely that an error in some translations is causing those problems. There’s a rake task that lists all problems found for a specific locale. You can run it inside your Docker container as well as in your development environment by executing the following command:

rake i18n:check[locale]
# replace "locale" with the short name of the language, e.g. "bg" for Bulgarian

The output for Bulgarian currently looks like this:

Are you curious about errors in all locales? Simply run rake i18n:check without the [locale] parameter…

How can I fix those errors?

  1. Visit Transifex and select the correct language and resource.

  2. Search for the problematic translation by using the key: filter.

    image

Why are there so many “Missing interpolation key” errors?

Some languages should always use the %{count} variable in pluralized strings. The rake tasks knows about them and always prints an error when that variable is missing. See Always use %{count} variable when translating pluralized strings for more about that.

How can I fix Message Format errors?

Translating Message Format can be a bit tricky, but there’s a pretty good topic that should get you started: Message Format support for localization

10 Mi Piace

First of all, gotta love Discourse and its community, you’re the best example how to approach solving problems with other people :slight_smile:

So, I took a look into the console and that’s what I got:

So, it means there’s a lot of not properly translated sentences, yeah? Or there may be some warnings which don’t always affect badly?

4 Mi Piace

No, all of those are errors and should be fixed.

3 Mi Piace

Gotcha, I’m gonna work on this :slight_smile:

4 Mi Piace

Cosa suggerisci di fare se vedo Impossibile controllare i file della lingua per XX (tutte le lingue)?

Ho provato a usare il multilingua con il Pavillon Plugin ma l’ho disabilitato e disinstallato. Sto cercando di sistemare tutto nei miei file della lingua da qualche settimana :slight_smile: