JavaScript

Intl.PluralRules オブジェクト


編集:2023.01.11 by T.A.

[Edge]。→

言語を考慮した複数形の書式化を可能にするオブジェクト。

コンストラクター
new Intl.PluralRules([locales[, options]])
新しい Intl.PluralRules オブジェクトを生成して返します。
静的メソッド
Intl.PluralRules.supportedLocalesOf(locales[, options])
複数形の書式化で対応可能な言語コードの文字列を配列で返します。
インスタンス メソッド
Intl.PluralRules.resolvedOptions()
Intl.PluralRules を考慮した複数形の書式化で計算されたオプションをオブジェクトで返します。
Intl.PluralRules.select(number)
Intl.PluralRules を考慮した複数形の書式化をして文字列で返します。
Intl.PluralRules.selectRange(startRange, endRange)
Intl.PluralRules を考慮した複数形の書式化で指定範囲の場合の結果を文字列で返します。
DA=new Intl.PluralRules('ar');  //アラビア語。
D=DA.select(0);  //=[string]:zero
D=DA.select(1);  //=[string]:one
D=DA.select(2);  //=[string]:two
D=DA.select(3);  //=[string]:few
D=DA.select(4);  //=[string]:few
D=DA.select(15);  //=[string]:many
D=DA.select(100);  //=[string]:other
DA=new Intl.PluralRules('ja');  //日本語。
D=DA.select(0);  //=[string]:other
D=DA.select(1);  //=[string]:other
D=DA.select(100);  //=[string]:other
DA=new Intl.PluralRules('en');  //英語。
D=DA.select(0);  //=[string]:other
D=DA.select(1);  //=[string]:one
D=DA.select(15);  //=[string]:other
D=DA.select(100);  //=[string]:other

テスト