Intl

Intl.PluralRules

Creates an Intl.PluralRules object that enables plural-sensitive formatting and language-specific rules for plurals

Syntax

JavaScript
new Intl.PluralRules(locales?, options?)

Parameters

ParameterTypeDescription
localesstring | string[]A BCP 47 language tag or array of tags
optionsIntl.PluralRulesOptionsOptions: type (cardinal or ordinal)

Return Value

An Intl.PluralRules object with a select() method

Examples

Basic Usage
const pr = new Intl.PluralRules('en-US')
console.log(pr.select(0)) // 'other'
console.log(pr.select(1)) // 'one'
console.log(pr.select(2)) // 'other'
Practical Example
const pr = new Intl.PluralRules('en-US', { type: 'ordinal' })
console.log(pr.select(1)) // 'one' (1st)
console.log(pr.select(2)) // 'two' (2nd)
console.log(pr.select(3)) // 'few' (3rd)
console.log(pr.select(4)) // 'other' (4th)
Advanced Usage
function pluralize(count: number, singular: string, plural: string, locale = 'en') {
  const pr = new Intl.PluralRules(locale)
  return pr.select(count) === 'one' ? singular : plural
}
console.log(pluralize(1, 'item', 'items')) // 'item'
console.log(pluralize(5, 'item', 'items')) // 'items'

Understanding Intl.PluralRules

The Intl.PluralRules method in JavaScript creates an Intl.PluralRules object that enables plural-sensitive formatting and language-specific rules for plurals. It belongs to the Intl object and is one of the most widely used methods for working with intl values in modern JavaScript and TypeScript applications.

The method signature is new Intl.PluralRules(locales?, options?). It accepts 2 parameters: locales, options. When called, it returns an intl.pluralrules object with a select() method. Understanding when and how to use PluralRules() helps you write more expressive, readable code.

Common use cases for Intl.PluralRules include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-numberformat, intl-listformat, intl-relativetimeformat, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Intl.PluralRules is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Intl Methods

Other methods in the Intl object

Related Tools

More Intl Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.