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

9 Likes

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 Likes

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

3 Likes

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

4 Likes

What you suggest to do if I see Failed to check locale files for XX (every languages)?

I tried to use multilanguage with Pavillon Plugin but I disabled and uninstalled it. I’m trying to fix everything on my language files from a few weeks :slight_smile: