CKTIS / JavaScript
Intl.PluralRules — selecting a plural category
Intl.PluralRules selects a grammatical number category using locale-specific rules. Its select method returns a category name, not an inflected word or a complete message.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
const rules = new Intl.PluralRules(locales, options);
rules.select(value);Intl.PluralRules belongs to the ECMA-402 internationalization standard, not the DOM. The instance method PluralRules.select, formally Intl.PluralRules.prototype.select(value), returns a category: zero, one, two, few, many, or other. The available subset depends on the locale; these names do not represent simple equality tests.
The default option type: "cardinal" concerns quantities. type: "ordinal" concerns positions in a sequence. The API does not translate or inflect words: your application maps categories to text and should provide an other fallback. Digit and rounding options can change the selected category.
The example explicitly selects en and cardinal rules instead of depending on the environment's default locale. Its expected output assumes English locale data is available. The specification is not a browser compatibility table: check target environments and locale availability with Intl.PluralRules.supportedLocalesOf(["en"]). API availability in Node 24 does not establish browser support.
Examples
const rules = new Intl.PluralRules("en", { type: "cardinal" });
const forms = { one: "file", other: "files" };
for (const count of [0, 1, 2]) {
const category = rules.select(count);
console.log(`${count} ${forms[category] ?? forms.other}`);
}Result
0 files 1 file 2 files
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.