JavaScript

Intl.PluralRules.prototype.selectRange() メソッド


編集:2023.01.11 by T.A.

[Edge]。→

Intl.PluralRules を考慮した複数形の書式化で指定範囲の結果を文字列で返します。

構文
Intl.PluralRules.selectRange(startRange, endRange)
Intl.PluralRules Intl.PluralRules
startRange ¶範囲の開始値を表す数値。
endRange ¶範囲の終了値を表す数値。

startRangeendRangeの大小関係は、どちらが大きくても構わないようです。

戻り値

文字列。以下の何れか zero、one、two、few、many、other。→

DA=new Intl.PluralRules('ar');  //アラビア語。
D=DA.selectRange(0, 1);  //0~1。
	//=[string]:zero
D=DA.selectRange(0, 10);  //0~10。
	//=[string]:few
D=DA.selectRange(0, 100);  //0~100。
	//=[string]:other
D=DA.selectRange(99, 100);  //99~100。
	//=[string]:other
D=DA.selectRange(10, 0);  //10~0。
	=[string]:other

PluralRules()select()


テスト