Plural Rules by Language with Intl.PluralRules
Understand how plural forms differ across languages using Intl.PluralRules. Learn about cardinal and ordinal categories, languages with complex plural systems, and practical ICU MessageFormat patterns.
Detailed Explanation
Intl.PluralRules: Language-Specific Plural Categories
Different languages have different rules for plural forms. English has two (singular and plural), but other languages can have up to six. Intl.PluralRules determines which plural category a number belongs to.
Plural Categories
The possible categories are: zero, one, two, few, many, other.
English (2 categories)
const en = new Intl.PluralRules('en');
en.select(0); // "other"
en.select(1); // "one"
en.select(2); // "other"
en.select(100); // "other"
Arabic (6 categories!)
const ar = new Intl.PluralRules('ar');
ar.select(0); // "zero"
ar.select(1); // "one"
ar.select(2); // "two"
ar.select(3); // "few" (3-10)
ar.select(11); // "many" (11-99)
ar.select(100); // "other" (100, 1000, ...)
Polish (4 categories)
const pl = new Intl.PluralRules('pl');
pl.select(1); // "one"
pl.select(2); // "few" (2-4, 22-24, ...)
pl.select(5); // "many" (5-21, 25-31, ...)
pl.select(1.5); // "other"
Ordinal Plurals
const en = new Intl.PluralRules('en', { type: 'ordinal' });
en.select(1); // "one" -> "1st"
en.select(2); // "two" -> "2nd"
en.select(3); // "few" -> "3rd"
en.select(4); // "other" -> "4th"
en.select(21); // "one" -> "21st"
Practical Usage: Building Plural Messages
function pluralize(count, locale, forms) {
const rule = new Intl.PluralRules(locale).select(count);
return forms[rule] || forms.other;
}
pluralize(1, 'en', {
one: '1 item',
other: `${count} items`,
});
// "1 item"
pluralize(5, 'en', {
one: '1 item',
other: `${count} items`,
});
// "5 items"
Languages by Complexity
| Categories | Languages |
|---|---|
| 1 (other only) | Chinese, Japanese, Korean, Vietnamese, Thai |
| 2 (one, other) | English, German, Spanish, Portuguese, Italian |
| 3 | French, Latvian, Romanian |
| 4 | Polish, Czech, Slovak, Slovenian |
| 6 | Arabic |
Use Case
Plural rules are essential for any application that displays count-dependent messages. 'You have 1 new message' vs 'You have 5 new messages' is simple in English, but Polish needs four different forms and Arabic needs six. Without Intl.PluralRules, developers had to hardcode language-specific plural logic or use heavy i18n libraries. The API provides the correct category for any number in any language, which is the foundation of ICU MessageFormat patterns used by i18n frameworks like react-intl and i18next.
Try It — Locale String Tester
Related Topics
List Formatting with Intl.ListFormat (And, Or, Unit)
Intl.ListFormat
Relative Time Formatting with Intl.RelativeTimeFormat
Intl.RelativeTimeFormat
Intl.NumberFormat Basics: Locale-Aware Number Formatting
Intl.NumberFormat
Intl.DisplayNames API: Language, Region, Script, and Currency Names
Intl.DisplayNames
Locale Fallback Chain: How Browsers Resolve Locale Requests
Advanced