CodePark/ questions / Plurals & messages
START PRACTICINGPRACTICE
Frontend question · Internationalization › Plurals & messages

What does this print?

const rules = new Intl.PluralRules("ar");
console.log([0, 1, 2, 5, 11, 100].map((n) => rules.select(n)).join(" "));
zero one two few many other

Arabic uses all six CLDR plural categories. 0 is zero, 1 is one, 2 is two, 3 to 10 are few, 11 to 99 are many, and 100 is other. So a translation of "N messages" into Arabic needs six versions of the sentence.

"
other one other other other other" is the tempting wrong answer. That is the English pattern (one for 1, other for the rest), and it is exactly what a count === 1 check produces.