Intl.PluralRules object enables plural-sensitive formatting and plural-related language rules.

构造函数

Intl.PluralRules.PluralRules()
创建新的 Intl.PluralRules 对象。

静态方法

Intl.PluralRules.supportedLocalesOf()

Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.

实例方法

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()
返回 String indicating which plural rule to use for locale-aware formatting.

范例

Using locales

This example shows some of the variations in localized plural rules. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the locales argument:

// 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'
					

规范

规范
ECMAScript 国际化 API (ECMA-402)
The definition of 'Intl.PluralRules' in that specification.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
PluralRules Chrome 63 Edge 18 Firefox 58 IE No Opera 50 Safari 13 WebView Android 63 Chrome Android 63 Firefox Android 58 Opera Android 46 Safari iOS 13 Samsung Internet Android 8.0 nodejs 10.0.0
10.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the PluralRules() 构造函数 了解更多细节。
PluralRules() 构造函数 Chrome 63 Edge 18 Firefox 58 IE No Opera 50 Safari 13 WebView Android 63 Chrome Android 63 Firefox Android 58 Opera Android 46 Safari iOS 13 Samsung Internet Android 8.0 nodejs 13.0.0
13.0.0
部分支持 10.0.0
Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the PluralRules instance silently falls back to en-US . To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.
resolvedOptions Chrome 63 Edge 18 Firefox 58 IE No Opera 50 Safari 13 WebView Android 63 Chrome Android 63 Firefox Android 58 Opera Android 46 Safari iOS 13 Samsung Internet Android 8.0 nodejs 10.0.0
10.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the PluralRules() 构造函数 了解更多细节。
select Chrome 63 Edge 18 Firefox 58 IE No Opera 50 Safari 13 WebView Android 63 Chrome Android 63 Firefox Android 58 Opera Android 46 Safari iOS 13 Samsung Internet Android 8.0 nodejs 10.0.0
10.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the PluralRules() 构造函数 了解更多细节。
supportedLocalesOf Chrome 63 Edge 18 Firefox 58 IE No Opera 50 Safari 13 WebView Android 63 Chrome Android 63 Firefox Android 58 Opera Android 46 Safari iOS 13 Samsung Internet Android 8.0 nodejs 10.0.0
10.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the PluralRules() 构造函数 了解更多细节。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: