initIntl
initIntl(options?) creates or replaces the package default runtime.
Use this at app entry, when one locale baseline should apply across the whole page.
ts
1import { initIntl } from '@beforesemicolon/intl'2 3initIntl({4 locale: navigator.language,5 fallbackLocale: 'en',6 srcDir: '/locales',7})Native API: `Intl.Locale`
Signature
ts
1function initIntl(options?: IntlRuntimeOptions): IntlRuntimeWhat happens when called
- destroys any existing default runtime
- creates a new default runtime from options
- default runtime becomes the fallback for
initIntl, helpers, and unscoped components
ts
1const runtime = initIntl({ locale: 'en-US', messages: { brand: 'Acme' } })Setup patterns
Page-level scoped files
ts
1initIntl({2 locale: 'en',3 src: '/locales/en.landing-page.json',4 fallbackLocale: 'en',5})Runtime inheritance
initIntl is for global defaults. For nested or isolated contexts, create dedicated runtimes with createIntl().
ts
1import { createIntl } from '@beforesemicolon/intl'2 3const child = createIntl({ locale: 'fr-FR', parentScope: initIntl() })Pairing with components
When components render outside <intl-locale>, they use this runtime.
html
1<intl-number type="currency" currency="USD">1299.99</intl-number>