/** A locale tag (e.g. `"en"`, `"es"`, `"ja"`) — a key into a {@link Catalog}. */ export type Locale = string; /** Flat message table for one locale: key → template string with `{param}` slots. */ export type Messages = Readonly>; /** All locales' message tables, keyed by locale. */ export type Catalog = Readonly>; /** Interpolation values for a message template. */ export type TParams = Readonly>; /** * Replace `{name}` placeholders in `template` with `params[name]`. Unknown * placeholders are left intact. Pure and locale-independent. */ export declare function interpolate(template: string, params?: TParams): string; /** Configuration for {@link createI18n}. */ export interface I18nOptions { catalog: Catalog; /** Active locale. Must be a key of `catalog` for lookups to resolve there. */ locale: Locale; /** Locale consulted when a key is missing in the active locale. */ fallbackLocale?: Locale; /** Invoked when a key resolves nowhere (dev warnings/telemetry); `t` still returns the key. */ onMissing?: (key: string, locale: Locale) => void; } /** Runtime translator over a message {@link Catalog} — active locale, lookup with fallback, interpolation, and pluralization. */ export interface I18n { locale(): Locale; /** Switch the active locale; notifies subscribers when it actually changes. */ setLocale(locale: Locale): void; /** Locales present in the catalog. */ locales(): readonly Locale[]; /** True when `key` resolves in the active or fallback locale. */ has(key: string): boolean; /** Translate `key`, interpolating `{param}` slots; returns `key` itself if it resolves nowhere. */ t(key: string, params?: TParams): string; /** * Plural-aware translate: picks `${key}.${category}` for the active locale's * Intl plural category (falling back to `${key}.other`, then `key`), with * `count` available as the `{count}` interpolation param. */ plural(key: string, count: number, params?: TParams): string; subscribe(listener: () => void): () => void; } /** * Create a translator over a message catalog: active-locale lookup with a * fallback-locale chain, `{param}` interpolation, and `Intl.PluralRules`-based * pluralization. Observable (`subscribe`) so React re-renders on `setLocale`; * the catalog is caller-owned static data, the locale is the only state. * * @capability i18n translate a message catalog with fallback-locale lookup, `{param}` interpolation, and Intl pluralization; observable active-locale switching */ export declare function createI18n(options: I18nOptions): I18n;