Firefox Tomorrow

javascript instance method

Intl.PluralRules.prototype.selectRange()

View on MDN ↗

The selectRange() method of PluralRules instances receives two values and returns a string indicating which plural rule to use for locale-aware formatting of the indicated range.

Syntax

selectRange(startRange, endRange)

Parameters

  • startRange
    • : A number representing the start of the range.
  • endRange
    • : A number representing the end of the range.

Return value

A string representing the pluralization category of the specified range. This can be one of zero, one, two, few, many or other, that are relevant for the locale whose localization is specified in LDML Language Plural Rules.

Description

This function selects a pluralization category according to the locale and formatting options of an PluralRules object.

Conceptually the behavior is the same as getting plural rules for a single cardinal or ordinal number. Languages have one or more forms for describing ranges, and this method returns the appropriate form given the supplied locale and formatting options. In English there is only one plural form, such as “1–10 apples”, and the method will return other. Other languages can have many forms.

Examples

Using selectRange()

new Intl.PluralRules("sl").selectRange(102, 201); // 'few'

new Intl.PluralRules("pt").selectRange(102, 102); // 'other'

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also