# Always use %{count} variable when translating pluralized strings

**URL:** https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969
**Category:** Translations
**Created:** [March 27, 2018, 2:31pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969 "2018-03-27T14:31:59Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 27, 2018, 2:31pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/1 "2018-03-27T14:31:59Z")

</div>

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](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html) 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:

- [Bosnian (bs)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#bs)

- [French (fr)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#fr)

- [Latvian (lv)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#lv)

- [Lithuanian (lt)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#lt)

- [Russian (ru)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#ru) – as explained in [Incorrect time delta on post (Ru interface only) - #7 by gerhard](https://meta.discourse.org/t/incorrect-time-delta-on-post-ru-interface-only/83390/7)

- [Slovenian (sl)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#sl) – the translations look OK

- [Serbian (sr)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#sr) – the translations look OK

- [Ukrainian (uk)](http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html#uk)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 27, 2018, 2:32pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/2 "2018-03-27T14:32:49Z")

</div>



---

<div class="post-metadata">

### Author: ![savas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/savas/32/131277_2.png) [@savas](https://meta.discourse.org/u/savas)
#### Post date: [August 31, 2018, 4:58pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/3 "2018-08-31T16:58:19Z")

</div>

Lithuanian language to 🙂

---

<div class="post-metadata">

### Author: ![Lure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lure/32/130462_2.png) [@Lure](https://meta.discourse.org/u/Lure)
#### Post date: [January 30, 2019, 10:48am UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/4 "2019-01-30T10:48:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [January 30, 2019, 11:04am UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/5 "2019-01-30T11:04:13Z")

</div>

Thanks for working on the Slovenian translations. We appreciate it! 👍

> [@Lure](#):
>
> The translation does not contain the same number of elements as the original phrase

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.

> [@Lure](#):
>
> The translation added a new placeholder: %{count}.

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.

> [@Lure](#):
>
> will you do another pull of latest translations for final 2.2 release?

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

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 20, 2019, 10:25pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/6 "2019-05-20T22:25:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 20, 2019, 10:25pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/7 "2019-05-20T22:25:59Z")

</div>



---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 20, 2019, 10:26pm UTC](https://meta.discourse.org/t/always-use-count-variable-when-translating-pluralized-strings/83969/8 "2019-05-20T22:26:03Z")

</div>


