JavaScript Intl.PluralRules Object
Intl.PluralRules tells you which plural form a number needs in a given language, such as one or other, so you can choose the right word or ending.
Description
Intl.PluralRules works out the plural category of a number for a locale. Its select() method returns one of 'zero', 'one', 'two', 'few', 'many' or 'other'. English only uses "one" and "other", but languages such as Arabic, Polish and Russian have more forms, so count === 1 isn't enough for translated text.
With type: 'ordinal', it gives categories for ordinal numbers, which you can map to suffixes like "st", "nd", "rd" and "th".
resolvedOptions().pluralCategories lists the categories a language uses, which is helpful when preparing translation files. It works hand in hand with Intl.NumberFormat: the number formatter shows the number correctly, and the plural rules pick the matching word. Translation libraries such as those based on ICU MessageFormat use Intl.PluralRules behind the scenes.
Creating
new Intl.PluralRules(locales, options)Example
Browser Support
The following information will show you the current browser support for the Intl.PluralRules object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





