Intl.getCanonicalLocales()

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

locales

Une liste de chaînes (String) dont on veut obtenir les noms canoniques pour les locales correspondantes.

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

BCD tables only load in the browser

Voir aussi