Intl.Locale.prototype.minimize()
method attempts to remove information about the locale that would be added by calling
Locale.maximize()
.
locale.minimize()
A
Locale
instance whose
baseName
property returns the result of the
Remove Likely Subtags
algorithm executed against
locale.baseName
.
This method carries out the reverse of
maximize()
, removing any language, script, or region subtags from the locale language identifier (essentially the contents of
baseName
). This is useful when there are superfluous subtags in the language identifier; for instance, "en-Latn" can be simplified to "en", since "Latn" is the only script used to write English.
minimize()
only affects the main subtags that comprise the
language identifier
: language, script, and region subtags. Other subtags after the "-u" in the locale indentifier are called extension subtags and are not affected by the
minimize()
method. Examples of these subtags include
Locale.hourCycle
,
Locale.calendar
,和
Locale.numeric
.
let myLocale = new Intl.Locale("fr-Latn-FR", {hourCycle: "h24", calendar: "gregory"});
console.log(myLocale.baseName); // Prints "fr-Latn-FR"
console.log(myLocale.toString()); // Prints "fr-Latn-FR-u-ca-gregory-hc-h24"
let myLocMinimized = myLocale.minimize();
// Prints "fr", since French is only written in the Latin script
// and is most likely to be spoken in France.
console.log(myLocMinimized.baseName);
// Prints "fr-u-ca-gregory-hc-h24".
// Note that the extension tags (after "-u") remain unchanged.
console.log(myLocMinimized.toString());
| 规范 |
|---|
| ECMAScript 国际化 API (ECMA-402) |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
minimize
|
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
12.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()