docs/src/docs/polyfills/intl-getcanonicallocales.mdx
A spec-compliant polyfill/ponyfill for Intl.getCanonicalLocales tested by the official ECMAScript Conformance test suite
<Tabs groupId="npm" defaultValue="npm" values={[ {label: 'npm', value: 'npm'}, {label: 'yarn', value: 'yarn'}, {label: 'pnpm', value: 'pnpm'}, ]}> <TabItem value="npm">
npm i @formatjs/intl-getcanonicallocales
yarn add @formatjs/intl-getcanonicallocales
pnpm add @formatjs/intl-getcanonicallocales
You can use polyfill-fastly.io URL Builder to create a polyfill script tag for Intl.GetCanonicalLocales. For example:
<!-- Polyfill Intl.GetCanonicalLocales & its dependencies -->
<script src="https://polyfill-fastly.io/v3/polyfill.min.js?features=Intl.GetCanonicalLocales"></script>
import '@formatjs/intl-getcanonicallocales/polyfill.js'
async function polyfill() {
// This platform already supports Intl.getCanonicalLocales
if (shouldPolyfill()) {
await import('@formatjs/intl-getcanonicallocales/polyfill.js')
}
// Alternatively, force the polyfill regardless of support
await import('@formatjs/intl-getcanonicallocales/polyfill-force.js')
}
This library is test262-compliant.