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

View in English Always switch to English

Intl.DisplayNames.prototype.resolvedOptions()

Baseline 広く利用可能

この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2021年4月以降、すべてのブラウザーで利用可能です。

resolvedOptions()Intl.DisplayNames インスタンスのメソッドで、現在の DisplayNames オブジェクトの初期化時に計算されたロケールとスタイルの書式オプションを反映したプロパティを持つ新しいオブジェクトを返します。

構文

js
resolvedOptions()

引数

なし。

返値

この DisplayNames オブジェクトの初期化時に計算されたオプションを反映したプロパティを持つ新しいオブジェクトです。このオブジェクトには、記載順に以下のプロパティがあります。

locale

実際に使用されているロケールの BCP 47 言語タグです。これは、ロケールネゴシエーションのプロセスによって決定されます。出力には、Unicode 拡張キーは記載されません。

style

options 引数でこのプロパティに指定された値です。必要に応じてデフォルト値が設定されます。値は "narrow""short""long" のいずれかです。デフォルト値は "long" です。

type

options 引数でこのプロパティに指定された値です。値は "language""region""script""currency""calendar""dateTimeField" のいずれかです。必須項目であるため、デフォルト値はありません。

fallback

options 引数でこのプロパティに指定された値です。"code" または "none" のどちらかです。デフォルト値は "code" です。

languageDisplay

options 引数でこのプロパティに指定された値です。"dialect" または "standard" のいずれかです。デフォルトは "dialect" です。

resolvedOptions の使用

js
const displayNames = new Intl.DisplayNames(["de-DE"], { type: "region" });

const usedOptions = displayNames.resolvedOptions();
console.log(usedOptions.locale); // "de-DE"
console.log(usedOptions.style); // "long"
console.log(usedOptions.type); // "region"
console.log(usedOptions.fallback); // "code"
js
const displayNames = new Intl.DisplayNames("en", {
  type: "language",
  languageDisplay: "standard",
});

const usedOptions = displayNames.resolvedOptions();
console.log(usedOptions.type); // "language"
console.log(usedOptions.languageDisplay); // "standard"

仕様書

仕様書
ECMAScript® 2027 Internationalization API Specification
# sec-Intl.DisplayNames.prototype.resolvedOptions

ブラウザーの互換性

関連情報