The Intl.DisplayNames()
constructor creates objects that enables the consistent translation of language, region and script display names.
new Intl.DisplayNames(locales, options)
locales
Optional
A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the locales
argument, see the Intl page. The following Unicode extension key is allowed:
nu
"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
"lookup"
and "best fit"
; the default is "best fit"
. For information about this option, see the Intl page.style
"long"
. "narrow"
"short"
"long"
type
"language"
"region"
"script"
"currency"
fallback
"code"
. "code"
"none"
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'
Specification |
---|
Intl.DisplayNames The definition of 'the Intl.DisplayNames constructor' in that specification. |
Desktop | ||||||
---|---|---|---|---|---|---|
DisplayNames() constructor |
81 | 81 | No | No | 68 | No |
Mobile | ||||||
---|---|---|---|---|---|---|
DisplayNames() constructor |
81 | 81 | No | 58 | No | No |
Server | |
---|---|
DisplayNames() constructor |
14.0.0 |
© 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/DisplayNames