Widely available すべての主要ブラウザで対応済み。安心して使用可能。

対応ブラウザ

機能 デスクトップ モバイル
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
63
18
58
13
63
13
ビルトインオブジェクト

Intl.PluralRules() コンストラクターは Intl/PluralRules オブジェクトを作成します。

63
18
58
13
63
13
Intl.PluralRules.PluralRules.options parameter

options`パラメータ

106
106
116
15.4
106
15.4
Intl.PluralRules.PluralRules.options parameter.options roundingIncrement parameter

`options.roundingIncrement` パラメータ

116
17.2
17.2
Intl.PluralRules.PluralRules.options parameter.options roundingMode parameter

`options.roundingMode` パラメータ

117
117
116
17.2
117
17.2
Intl.PluralRules.PluralRules.options parameter.options roundingPriority parameter

「options.roundingPriority」パラメータ

106
106
116
15.4
106
15.4
Intl.PluralRules.PluralRules.options parameter.options trailingZeroDisplay parameter
実験的

「options.trailingZeroDisplay」パラメータ

116

Intl.PluralRules.prototype.resolvedOptions() メソッドは、この Intl.PluralRules オブジェクトの初期化時に計算されたロケールと照合オプションを反映したプロパティを持つ新しいオブジェクトを返します。

63
18
58
13
63
13

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

63
18
58
13
63
13

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

106
106
116
15.4
106
15.4

Intl.PluralRules.supportedLocalesOf() メソッドは、ランタイムの既定のロケールのうち、代替する必要なく複数形の書式で対応されているものが入った配列を返します。

63
18
58
13
63
13
1+対応 (バージョン) 未対応 注釈あり サブ機能の解説は MDN Web Docs (CC BY-SA 2.5)

基本構文

JAVASCRIPT
const pr = new Intl.PluralRules('ja');
pr.select(1); // 'other' (Japanese has no plural form)

const en = new Intl.PluralRules('en');
en.select(1); // 'one'
en.select(2); // 'other'

ライブデモ

Intl.PluralRules

Number. Multipleshapel-l read.word language per and. complex multipleshape to support.

プレビュー全画面表示

word language per and. kacategory

word language to multipleshape. kacategorynumber that different.

プレビュー全画面表示

Ordinal (number)

1st, 2nd, 3rd equal. number. notationl-l.

プレビュー全画面表示

実務での使いどころ

  • Intl.PluralRules の活用

    Intl.PluralRules オブジェクトは、複数形が影響する書式や言語ルールを使用できるようにします。

注意点

  • 特になし。すべての主要ブラウザで安定して動作する。

アクセシビリティ

  • JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。