Intl.getCanonicalLocales()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.
La méthode Intl.getCanonicalLocales()
renvoie un tableau contenant les noms canoniques des locales. Les doublons seront fusionnés et les éléments passés en arguments doivent être des étiquettes de langues valides.
Exemple interactif
Syntaxe
js
Intl.getCanonicalLocales(locales);
Paramètres
Valeur de retour
Un tableau qui contient les noms canoniques des locales.
Exemples
js
Intl.getCanonicalLocales("EN-US"); // ["en-US"]
Intl.getCanonicalLocales(["EN-US", "Fr"]); // ["en-US", "fr"]
Intl.getCanonicalLocales("EN_US");
// RangeError:'EN_US' is not a structurally valid language tag
Spécifications
Specification |
---|
ECMAScript Internationalization API Specification # sec-intl.getcanonicallocales |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getCanonicalLocales |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.