Die Intl.getCanonicalLocales()
Methode gibt ein Array mit den anerkannten Gebietsnamen zurück. Duplikate werden verhindert und Elemente werden auf valide Sprach-Tag-Struktur geprüft.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Intl.getCanonicalLocales(locales)
Parameter
locales
- Eine List von
String
Werten, von welchen die anerkannten Gebietsnamen gesucht werden.
Rückgabewert
Ein Array mit den anerkannten Gebietsnamen.
Beispiele
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
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript Internationalization API (ECMA-402) Die Definition von 'Intl.getCanonicalLocales' in dieser Spezifikation. |
Lebender Standard | Initiale Definition |
Browserkompatibilität
BCD tables only load in the browser
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.