Intl.ListFormat
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 conforme à la spécification pour Intl.ListFormat, entièrement validé par la suite de tests de conformité ECMAScript officielle
Installation
- npm
- yarn
npm i @formatjs/intl-listformat
yarn add @formatjs/intl-listformat
Prérequis
Utilisation
Via polyfill-fastly.io
Utilisez le Générateur d'URL polyfill-fastly.io pour créer une balise script de polyfill pour Intl.ListFormat. Par défaut, l'URL générée ne contient aucune donnée de locale. Pour ajouter des données de locale, ajoutez Intl.ListFormat.~locale.<locale> à votre liste de fonctionnalités. Par exemple :
<!-- Polyfill Intl.ListFormat, its dependencies & `en` locale data -->
<script src="https://polyfill-fastly.io/v3/polyfill.min.js?features=Intl.ListFormat,Intl.ListFormat.~locale.en"></script>
Exemple simple
import '@formatjs/intl-listformat/polyfill'
import '@formatjs/intl-listformat/locale-data/en' // locale-data for en
Import dynamique + détection de capacités
import {shouldPolyfill} from '@formatjs/intl-listformat/should-polyfill'
async function polyfill(locale: string) {
const unsupportedLocale = shouldPolyfill(locale)
// This locale is supported
if (!unsupportedLocale) {
return
}
// Load the polyfill 1st BEFORE loading data
await import('@formatjs/intl-listformat/polyfill-force')
await import(`@formatjs/intl-listformat/locale-data/${unsupportedLocale}`)
}
Tests
Cette bibliothèque est entièrement conforme à test262.