このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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 ⁨2019年9月⁩.

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

ブラウザーの互換性

関連情報