How to check locale files for errors

(Gerhard Schlager) #1

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.


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

(Sevos) #2

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?

(Gerhard Schlager) #3

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

(Sevos) #4

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

(Gerhard Schlager) #13