该对象的英文请立即获取iTunes多种敏感格式状语从句：多种语言规则的对象的构造函数。`Intl.PluralRules`

## 句法

    new Intl.PluralRules([locales[, options]]) Intl.PluralRules.call(this[, locales[, options]])

### 参数

`locales`

  可选的。一个带有BCP 47语言标签的字符串或这种字符串的数组。有关参数的一般形式和解释 `locales`，请参阅 Intl page。

`options`

  可选的，具有部分或全部以下属性的对象：

  `localeMatcher`
    要使用的语言环境匹配算法。可能的值是`"lookup"`和`"best fit"`; 默认是`"best fit"`。有关此选项的信息，请参阅 Intl page。
  `type`
    要使用的类型。可能的值是：
    - `"cardinal"`对于基数（指的是事物的数量）。这是默认值。
    - `"ordinal"` 对于序号（指的是事物的排序或排名，例如英文中的“1st”，“2nd”，“3rd”）。

## 描述

### 属性

`Intl.PluralRules.prototype`
  允许为所有对象添加属性。

### 方法

`Intl.PluralRules.supportedLocalesOf()`
  返回一个数组，其中包含提供的语言环境的支持，而不必回退到运行时的默认语言环境。

## `PluralRules` 实例

### 属性

`PluralRules` 实例从其原型继承了以下属性：

`Intl.PluralRules.prototype.constructor`
  A reference to `Intl.PluralRules`.

### 方法

`PluralRules` 实例从它们的原型继承了以下方法：

`Intl.PluralRules.prototype.resolvedOptions()`
  Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.
`Intl.PluralRules.prototype.select()`
  Returns a `String` indicating which plurar rule to use for locale-aware formatting.

## 例子

### 基本用法

在没有指定语言环境的基本使用中，返回默认语言环境中的格式化字符串和默认选项。这有助于区分单数和复数形式，例如“dog”和“dogs”。

    var pr = new Intl.PluralRules();

    pr.select(0);
    // → 'other' if in US English locale

    pr.select(1);
    // → 'one' if in US English locale

    pr.select(2);
    // → 'other' if in US English locale

### 运用 `locales`

这个例子展示了局部复数规则的一些变化。为了获得应用程序用户界面中使用的语言格式，请确保使用 `locales` 参数指定该语言（可能还有一些备用语言）：

    // Arabic has different plural rules

    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'

### 运用 `options`

可以查询查询结果使用 `options` 参数进行自定义，该参数具有一个 `type` 您可以设置的属性 `ordinal`。这对计算序数指标很有用，例如“第一”，“第二”，“第三”，“第四”，“42”等。

    var pr = new Intl.PluralRules('en-US', { type: 'ordinal' });

    pr.select(0);
    // → 'other'
    pr.select(1);
    // → 'one'
    pr.select(2);
    // → 'two'
    pr.select(3);
    // → 'few'
    pr.select(4);
    // → 'other'
    pr.select(42);
    // → 'two'

## 规范

规范 | 状态 | 评论
--- | --- | ---
国际复数规则草案 | Draft | 初始定义

## 浏览器兼容性

此页面上的兼容性表格由结构化数据生成。如果您想为数据做出贡献，请查看 https://github.com/mdn/browser-compat-data 并向我们发送拉取请求。

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
`PluralRules` | Chrome Full support 63 | Edge Full support 18 | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`PluralRules()` constructor | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`prototype` | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`resolvedOptions` | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`select` | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`supportedLocalesOf` | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 58 | IE No support No | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android Full support 58 | Opera Android Full support 50 | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No

### Legend

Full support
  Full support
No support
  No support

## 也可以看看

- Introduction: The ECMAScript Internationalization API
- Constructors
  - `Intl.Collator`
  - `Intl.DateTimeFormat`
  - `Intl.ListFormat`
  - `Intl.NumberFormat`
  - `Intl.PluralRules`
  - `Intl.RelativeTimeFormat`
- Methods
  - `String.prototype.localeCompare()`
  - `Number.prototype.toLocaleString()`
  - `Date.prototype.toLocaleString()`
  - `Date.prototype.toLocaleDateString()`
  - `Date.prototype.toLocaleTimeString()`