Intl.PluralRules.prototype.resolvedOptions()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2019.

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

試してみましょう

const pluralRules1 = new Intl.PluralRules("uk");
const options1 = pluralRules1.resolvedOptions();

const pluralRules2 = new Intl.PluralRules("bn");
const options2 = pluralRules2.resolvedOptions();

console.log(options1.pluralCategories);
// Expected output: Array ["few", "many", "one", "other"]

console.log(options2.pluralCategories);
// Expected output: Array ["one", "other"]

構文

js
resolvedOptions();

返値

この Intl.PluralRules オブジェクトの初期化時に計算されたロケールと照合オプションを反映したプロパティを持つ新しいオブジェクトです。

解説

返されるオブジェクトには以下のプロパティがあります。

locale

実際に使用したロケールの BCP 47 言語タグ。このロケールにつながる入力 BCP 47 言語タグに Unicode 拡張値が要求された場合、要求されたキーと値の組のうち、このロケールで対応しているものが locale に含まれます。

pluralCategories

指定されたロケールで使用される複数形カテゴリーの Array で、 "zero", "one", "two", "few", "many", "other" のリストの中から選択します。

type

使用される種類です (cardinal または ordinal)。

以下の 2 つのプロパティのグループの中では、 1 つだけしか設定できません。

minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits

これらのプロパティには、 options 引数で指定された値が入るか、既定値で埋められます。これらのプロパティは minimumSignificantDigitsmaximumSignificantDigits のどちらも options 引数で指定されなかった場合のみ存在します。

minimumSignificantDigits, maximumSignificantDigits

これらのプロパティには、 options 引数で指定された値が入るか、既定値で埋められます。これらのプロパティは、少なくとも 1 つのプロパティが options 引数で提供された場合にのみ表示されます。

resolvedOptions() メソッドの使用

js
var de = new Intl.PluralRules("de-DE");
var usedOptions = de.resolvedOptions();

usedOptions.locale; // "de-DE"
usedOptions.maximumFractionDigits; // 3
usedOptions.minimumFractionDigits; // 0
usedOptions.minimumIntegerDigits; // 1
usedOptions.pluralCategories; // Array [ "one", "other" ]
usedOptions.type; // "cardinal"

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-intl.pluralrules.prototype.resolvedoptions

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
resolvedOptions

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

関連情報