此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Intl.PluralRules

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2019年9月.

* Some parts of this feature may have varying levels of support.

>

Intl.PluralRules 对象是用于复数敏感的格式化和复数相关的语言规则。

构造函数

Intl.PluralRules()

创建一个新的 Intl.PluralRules 对象。

静态方法

Intl.PluralRules.supportedLocalesOf()

返回一个数组,其中包含提供的区域(locale)中被运行时所支持的,而不必回退到运行时的默认区域。

实例方法

Intl.PluralRules.prototype.resolvedOptions()

返回一个新的对象,其属性反映了在对象初始化期间计算所得的区域和一系列选项。

Intl.PluralRules.prototype.select()

返回一个字符串,指示用于区域敏感的格式化的复数类别。

Intl.PluralRules.prototype.selectRange()

此方法接收两个值并返回一个字符串,指示用于区域敏感的格式化的复数类别。

示例

>

使用 locales

此示例显示本地化复数类别的一些值。为了获得应用程序用户界面中使用的语言格式,请确保使用 locales 参数指定了语言(可能还有一些回退语言):

js
// 阿拉伯语有不同的复数类别

new Intl.PluralRules("ar-EG").select(0);
// → 'zero'
new Intl.PluralRules("ar-EG").select(1);
// → 'one'
new Intl.PluralRules("ar-EG").select(2);
// → 'two'
new Intl.PluralRules("ar-EG").select(6);
// → 'few'
new Intl.PluralRules("ar-EG").select(18);
// → 'many'

规范

Specification
ECMAScript® 2026 Internationalization API Specification>
# pluralrules-objects>

浏览器兼容性

参见