Intl.DisplayNames.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 April 2021.

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

構文

js
resolvedOptions();

返値

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

解説

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

locale

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

style

コンストラクターの options 引数でこのプロパティに与えられた値、または既定値 ("long") です。値は "long"、"short"、"narrow" のいずれかです。

type

コンストラクターの options 引数でこのプロパティに与えられた値、または既定値 ("language") です。値は "language"、"region"、"script"、"currency" のいずれかです。

fallback

コンストラクターの options 引数でこのプロパティに与えられた値、または既定値 ("code") です。値は "code" または "none" のどちらかです。

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"

仕様書

Specification
ECMAScript® 2025 Internationalization API Specification
# sec-Intl.DisplayNames.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

関連情報