Intl.PluralRules.select()

Intl.PluralRules.prototype.select() メソッドは、ロケールを考慮した書式設定に使用する複数形ルールを示す文字列を返します。

試してみましょう

構文

js
select(number);

引数

number

複数のルールを取得するための数値です。

返値

数字の複数形のカテゴリーを表す文字列で、 zero, one, two, few, many, other のいずれかになります。

解説

この関数は、 Intl.PluralRules オブジェクトのロケールや書式オプションに応じて、複数形のカテゴリーを選択します。

select() の使用

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 Internationalization API Specification
# sec-intl.pluralrules.prototype.select

ブラウザーの互換性

BCD tables only load in the browser

関連情報