Plurals

Plural can be combined with interpolation, context, ...

These plurals are streamlined with the one used in the Intl APIarrow-up-right. =>You need to polyfillarrow-up-right the Intl.PluralRulesarrow-up-right API.

triangle-exclamation
circle-info

If you need multiple counts, take a look at nesting

circle-info

We provide the ability to have special translation for {count: 0}, so that a more natural language can be used. If the count is 0, and a _zero entry is present, then it will be used instead of the language plural suffix.

circle-info

๐ŸŽ“ Check out this topic in the i18next crash course videoarrow-up-right.

Singular / Plural

keys

{
  "key_one": "item",
  "key_other": "items",
  "keyWithCount_one": "{{count}} item",
  "keyWithCount_other": "{{count}} items"
}

sample

i18next.t('key', {count: 0}); // -> "items"
i18next.t('key', {count: 1}); // -> "item"
i18next.t('key', {count: 5}); // -> "items"
i18next.t('key', {count: 100}); // -> "items"
i18next.t('keyWithCount', {count: 0}); // -> "0 items"
i18next.t('keyWithCount', {count: 1}); // -> "1 item"
i18next.t('keyWithCount', {count: 5}); // -> "5 items"
i18next.t('keyWithCount', {count: 100}); // -> "100 items"
circle-exclamation

Languages with multiple plurals

Sample uses arabic which has 5 plural forms beside the singular.

keys

sample

How to find the correct plural suffix?

You can use this small utility to get the correct plural suffixes.

source codearrow-up-right

Or try translation-checkarrow-up-right, it shows an overview of your translations in a nice UI. It shows also the appropriate plural forms.

Or you use a smart translation management system, like locizearrow-up-right

Ordinal plurals

There is also support for ordinal numbers (referring to the ordering or ranking of things, e.g. "1st", "2nd", "3rd" in English). The ordinal option (and the _ordinal suffix) tells the helper to use the ordinal digit to determine the plurality key used. E.g., for "32" the ordinal digit is "2" so key_two is used.

keys

sample

Interval plurals

Want to define phrases expressing the number of items lies in a range. Like a few items or a lot of items.

You will need to add a post processor: i18next-intervalplural-postprocessorarrow-up-right

keys

sample

triangle-exclamation

Last updated