W3cubDocs

/JavaScript

Intl.locale.minimize

The Intl.Locale.prototype.minimize() method attempts to remove information about the locale that would be added by calling Locale.maximize().

Syntax

locale.minimize()

Return value

A Locale instance whose baseName property returns the result of the Remove Likely Subtags algorithm executed against locale.baseName.

Description

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, and Locale.numeric.

Examples

Using minimize

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());

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
minimize 74 79 75 No 62 14
14
Safari 14 Technology Preview 107-111 returns a string instead of a Locale object.
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
minimize 74 74 No 53 14
14
Safari 14 Technology Preview 107-111 returns a string instead of a Locale object.
11.0
Server
Node.js
minimize 12.0.0
12.0.0
Before version 13.0.0, only the locale data for en-US is available by default. See the Locale() constructor for more details.

See also

© 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/Locale/minimize