Intl.DisplayNames.prototype.resolvedOptions() - JavaScript 编辑
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
Specification |
---|
Intl.DisplayNames The definition of 'resolvedOptions()' in that specification. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论