Web/JavaScript/Reference/Global objects/Intl/DisplayNames/DisplayNames
The Intl.DisplayNames() constructor creates objects that enables the consistent translation of language, region and script display names.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
new Intl.DisplayNames(locales, options)
Parameters
localesOptional- A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the
localesargument, see the Intl page. The following Unicode extension key is allowed:
nu- The numbering system to be used. Possible values include:
"arab","arabext","bali","beng","deva","fullwide","gujr","guru","hanidec","khmr","knda","laoo","latn","limb","mlym","mong","mymr","orya","tamldec","telu","thai","tibt".
options- An object with some or all of the following properties:
localeMatcher- The locale matching algorithm to use. Possible values are
"lookup"and"best fit"; the default is"best fit". For information about this option, see the Intl page. style- The formatting style to use, the default is
"long".
"narrow""short""long"
type- The type to use.
"language""region""script""currency"
fallback- The fallback to use, the default is
"code".
"code""none"
Examples
Basic usage
In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.
console.log((new Intl.DisplayNames([], {type: 'language'})).of('US'));
// Expected output: 'us'
Specifications
| Specification |
| Intl.DisplayNamesThe definition of 'the Intl.DisplayNames constructor' in that specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DisplayNames() constructor
|
Chrome
Full support 81 |
Edge
Full support 81 |
Firefox
No support No |
IE
No support No |
Opera
Full support 68 |
Safari
No support No |
WebView Android
Full support 81 |
Chrome Android
Full support 81 |
Firefox Android
No support No |
Opera Android
Full support 58 |
Safari iOS
No support No |
Samsung Internet Android
No support No |
nodejs
Full support 14.0.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
Intl.DisplayNames() constructor by Mozilla Contributors is licensed under CC-BY-SA 2.5.