Intl.ListFormat
Inoffizielle Beta-Übersetzung
Diese Seite wurde von PageTurner AI übersetzt (Beta). Nicht offiziell vom Projekt unterstützt. Fehler gefunden? Problem melden →
Eine spezifikationskonforme Polyfill-Implementierung für Intl.ListFormat, vollständig getestet durch die offizielle ECMAScript-Konformitätstestsuite
Installation
- npm
- yarn
npm i @formatjs/intl-listformat
yarn add @formatjs/intl-listformat
Anforderungen
-
Intl.Localeoder Polyfill.
Verwendung
Über polyfill-fastly.io
Mit dem polyfill-fastly.io URL Builder können Sie ein Polyfill-Script-Tag für Intl.ListFormat erstellen. Standardmäßig enthält die generierte URL keine Lokalisierungsdaten. Um Lokalisierungsdaten hinzuzufügen, ergänzen Sie Intl.ListFormat.~locale.<locale> in Ihrer Feature-Liste. Beispiel:
<!-- 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>
Einfach
import '@formatjs/intl-listformat/polyfill'
import '@formatjs/intl-listformat/locale-data/en' // locale-data for en
Dynamischer Import + Funktionserkennung
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
Diese Bibliothek ist vollständig test262-konform.