W3cubDocs

/JavaScript

Intl.displayNames.resolvedOptions

The Intl.DisplayNames.prototype.resolvedOptions() method returns a new object with properties reflecting the locale and style formatting options computed during the construction of the current DisplayNames object.

Syntax

displayNames.resolvedOptions()

Return value

An object with properties reflecting the locale and formatting options computed during the construction of the given DisplayNames object.

Description

The object returned by resolvedOptions() has the following properties:

locale
The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in locale.
style
The value provided for this property in the options argument of the constructor or the default value ("long"). Its value is either "long", "short", or "narrow".
type
The value provided for this property in the options argument of the constructor or the default value ("language"). Its value is either "language", "region", "script", or "currency".
fallback
The value provided for this property in the options argument of the constructor or the default value ("code"). Its value is either "code" or "none".

Examples

Using resolvedOptions

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"

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
resolvedOptions 81 81 No No 68 No
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
resolvedOptions 81 81 No 58 No No
Server
Node.js
resolvedOptions 14.0.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions