Intl.getCanonicalLocales
Traduction Bêta Non Officielle
Cette page a été traduite par PageTurner AI (bêta). Non approuvée officiellement par le projet. Vous avez trouvé une erreur ? Signaler un problème →
Un polyfill/ponyfill conforme à la spécification pour Intl.getCanonicalLocales, testé par la suite officielle de tests de conformité ECMAScript
Installation
- npm
- yarn
npm i @formatjs/intl-getcanonicallocales
yarn add @formatjs/intl-getcanonicallocales
Utilisation
Via polyfill-fastly.io
Vous pouvez utiliser le Générateur d'URL polyfill-fastly.io pour créer une balise script de polyfill pour Intl.GetCanonicalLocales. Par exemple :
<!-- Polyfill Intl.GetCanonicalLocales & its dependencies -->
<script src="https://polyfill-fastly.io/v3/polyfill.min.js?features=Intl.GetCanonicalLocales"></script>
Exemple simple
import '@formatjs/intl-getcanonicallocales/polyfill'
Import dynamique + détection de capacités
import {shouldPolyfill} from '@formatjs/intl-getcanonicallocales/should-polyfill'
async function polyfill() {
// This platform already supports Intl.getCanonicalLocales
if (shouldPolyfill()) {
await import('@formatjs/intl-getcanonicallocales/polyfill')
}
// Alternatively, force the polyfill regardless of support
await import('@formatjs/intl-getcanonicallocales/polyfill-force')
}
Tests
Cette bibliothèque est conforme à la norme test262.