@stalkerg/precompile-intl-runtime
v1.0.1
Published
Runtime helpers to be used in translations precompiled by babel-plugin-precompile-intl
Downloads
472
Maintainers
Readme
@stalkerg/precompile-intl-runtime
Internal Svelte 5 runtime used by @stalkerg/svelte-icu and the precompiled
ICU message functions.
The runtime has two layers:
- pure TypeScript lookup, locale fallback, loaders, and cached
Intlhelpers; - an instance-based
I18nstate core implemented in a.svelte.tsmodule and exposed through a callable function facade.
There is no mutable module-level locale, dictionary, or loading store. An
I18n instance owns the mutable data for one component tree/request, while
immutable loader results and Intl formatter caches may safely be shared.
An instance translates directly with i18n('key', values). The small facade is
not a Proxy; it delegates to private rune state. The temporary i18n.t alias
from the first two alphas was removed instead of maintaining two spellings for
the same operation.
syncDocumentLanguage(i18n) is an optional, tree-shakeable Svelte effect that
keeps the browser's <html lang> attribute synchronized with an instance. It
does not run during SSR and is never enabled merely by importing the package.
setMessages(locale, catalog) installs a complete loaded catalog and replaces
the previous setMessages layer for that locale. addMessages is the separate
API for accumulating partial overlays. Partial catalogs are applied in argument
order even when one spells a key as account.title and another spells the same
key as { account: { title: ... } }.
Most users should install and import @stalkerg/svelte-icu instead of this
package directly. See the
migration guide.
This runtime package requires Node 24.11.0 or newer and is ESM-only.
The generated-helper contract preserves ICU semantics for the supported MF1 subset: it distinguishes missing own properties from supplied values, validates argument types, formats typeless numbers and dates with the message locale, uses half-even rounding, and evaluates complex-message fragments lazily. The runtime still accepts the v2 helper call shapes emitted by the stable 1.0.0 compiler so previously generated catalogs remain executable after an upgrade.
