Intl.Locale
constructor is a standard built-in property of the Intl object that represents a Unicode locale identifier.
new Intl.Locale(tag [, options])
tag
The Unicode locale identifier string.
options
An object that contains configuration for the Locale. Keys are Unicode locale tags, values are valid Unicode tag values.
At its very simplest, the
Intl.Locale
constructor takes a locale identifier string as its argument:
let us = new Intl.Locale('en-US');
The constructor also takes an optional configuration object argument, which can contain any of several extension types. For example, set the
hourCycle
property of the configuration object to your desired hour cycle type, and then pass it into the constructor:
let us12hour = new Intl.Locale("en-US", {hourCycle: "h12"});
console.log(us12hour.hourCycle); // Prints "h12"
| 规范 |
|---|
| ECMAScript 国际化 API (ECMA-402) |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Locale()
构造函数
|
Chrome 74 | Edge 79 | Firefox 75 | IE No | Opera 62 | Safari 14 | WebView Android 74 | Chrome Android 74 | Firefox Android No | Opera Android 53 | Safari iOS 14 | Samsung Internet Android 11.0 |
nodejs
13.0.0
|
完整支持
不支持
见实现注意事项。
Intl
Collator
DateTimeFormat
ListFormat
NumberFormat
PluralRules
RelativeTimeFormat
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()