Aller au contenu principal

Intl.Locale

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.Locale validé par la suite de tests de conformité ECMAScript officielle

npm Version size

Installation

npm i @formatjs/intl-locale

Prérequis

Utilisation

Via polyfill-fastly.io

Vous pouvez utiliser le constructeur d'URL polyfill-fastly.io pour créer une balise script de polyfill pour Intl.Locale. Par exemple :

<!-- Polyfill Intl.Locale & its dependencies -->
<script src="https://polyfill-fastly.io/v3/polyfill.min.js?features=Intl.Locale"></script>

Exemple simple

import '@formatjs/intl-locale/polyfill'

Import dynamique + détection de capacités

import {shouldPolyfill} from '@formatjs/intl-locale/should-polyfill'
async function polyfill() {
// This platform already supports Intl.Locale
if (shouldPolyfill()) {
await import('@formatjs/intl-locale/polyfill')
}
// Alternatively, force the polyfill regardless of support
await import('@formatjs/intl-locale/polyfill-force')
}

Tests

Cette bibliothèque est conforme à test262.