Intl.PluralRules.prototype.select method returns a String indicating which plural rule to use for locale-aware formatting.

句法

pluralCategory = pluralRule.select(number)
					

参数

number

The number to get a plural rule for.

返回值

A string representing the pluralization category of the number , can be one of zero , one , two , few , many or other .

描述

This function selects a pluralization category according to the locale and formatting options of a PluralRules 对象。

范例

Using select()

 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.select()' 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
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() 构造函数 了解更多细节。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: