Always use %{count} variable when translating pluralized strings

Some languages use the “zero” and/or “one” key for more than the values 0 and 1. Please use the correct variable (like %{count}) if you are translating one of those languages. The actual value will be truncated to the static value used in the translation if you aren’t using the variable.

Take a look at the list of Plural Rules provided by Unicode if you are not completely sure about your language.

I identified the following languages available in Discourse where translators need to be careful when translating pluralized strings:

9 Likes

Lithuanian language to :slight_smile:

3 Likes

I am working on Slovenian translations for 2.2 release and was fixing plurals today. Sometimes “one” in original (English) does not include {{count}} or %{count} - it just uses literal 1 and then I get warning or even error in Transifex.

For example on key admin_js.admin.flags.replies I have added %{count} to “one” translation and now I cannot save it due to error:

The translation does not contain the same number of elements as the original phrase

Interesting enough, I did get only warning on other similar cases (e.g. key: js.badges.granted):

The translation added a new placeholder: %{count}.

How can I fix that?

BTW, will you do another pull of latest translations for final 2.2 release? Would really like to have recent work included in final release.

1 Like

Thanks for working on the Slovenian translations. We appreciate it! :+1:

Looks like there’s a problem with the “Lists are preserved in the translations.” check on Transifex. There’s is no list in that text, so it shouldn’t create an error. I updated the check so that it only creates a warning for now.

You can ignore that warning. I’m going to update to English translations after the 2.2 release and will make sure that we are always using %{count} instead of 1. Those warnings will disappear afterwards.

Yes, we will update the translations for the final release.

3 Likes

All locale files as well as all the translations on Transifex have been updated. There shouldn’t be any pluralized strings anymore where the one key contains the number 1 instead of %{count}.

I re-enabled the the checks on Transifex and added a spec to Discourse which should prevent us from introducing new pluralized strings with missing %{count} interpolation keys.

Please open a new topic if you encounter problems related to these changes.

4 Likes