Intl.getCanonicalLocales
A spec-compliant polyfill/ponyfill for Intl.getCanonicalLocales
tested by the official ECMAScript Conformance test suite
Installation​
- npm
- yarn
npm i @formatjs/intl-getcanonicallocales
yarn add @formatjs/intl-getcanonicallocales
Usage​
Via polyfill.io​
You can use polyfill.io URL Builder to create a polyfill script tag for Intl.GetCanonicalLocales
. For example:
<!-- Polyfill Intl.GetCanonicalLocales & its dependencies -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=Intl.GetCanonicalLocales"></script>
Simple​
import '@formatjs/intl-getcanonicallocales/polyfill'
Dynamic import + capability detection​
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')
}
}
Tests​
This library is test262-compliant.