/** * @module i18n * Internationalization support with namespace-based translations. * Uses ICU message format for pluralization, select, and formatting. * * @example * // Initialize locale * await setLocale('sv'); * * // Use translations * const greeting = t('r-common:greeting', { name: 'John' }); * const items = t('shop:items', { count: 5 }); */ type Namespace = string; export type MissingTranslationHandler = (key: string, namespace: string, locale: string) => void; /** * Dispatched on `document` after `setLocale()` completes. * The `locale` property contains the new normalized locale code. * * @example * document.addEventListener('localechange', (e) => { * console.log(`Locale changed to ${e.locale}`); * this.render(); * }); */ export declare class LocaleChangeEvent extends Event { readonly locale: string; constructor(locale: string); } declare global { interface DocumentEventMap { localechange: LocaleChangeEvent; } } /** * Sets the current locale and loads the common namespace. * Clears previously loaded translations and dispatches a `localechange` event. * * @param locale - The locale code (e.g., 'en', 'sv', 'en-US') * * @example * await setLocale('sv'); */ export declare function setLocale(locale: string): Promise; /** * Loads a translation namespace on demand. * Falls back to the default locale if translations are not found. * * @param namespace - The namespace to load (e.g., 'shop', 'errors') * * @example * await loadNamespace('shop'); * const price = t('shop:priceLabel'); */ export declare function loadNamespace(namespace: Namespace): Promise; /** * Loads multiple translation namespaces in parallel. * * @param namespaces - Array of namespace names to load * * @example * await loadNamespaces(['r-pipes', 'r-validation']); */ export declare function loadNamespaces(namespaces: Namespace[]): Promise; /** * Translates a key with optional value interpolation. * Supports ICU message format for pluralization and select. * * @param fullKey - Translation key in format 'namespace:key' or just 'key' (uses 'r-common') * @param values - Values to interpolate into the message * @returns The translated string, or the key if not found * * @example * // Simple translation * t('greeting'); // Uses r-common:greeting * * // With namespace * t('errors:notFound'); * * // With interpolation * t('welcome', { name: 'John' }); // "Welcome, John!" * * // With pluralization (ICU format) * t('items', { count: 5 }); // "5 items" or "5 föremål" */ export declare function t(fullKey: string, values?: Record): string; /** * Returns the current locale code. * * @returns The normalized locale code (e.g., 'en', 'sv') */ export declare function getCurrentLocale(): string; /** * Registers a handler called when `t()` encounters a missing translation key. * Pass `null` to remove the handler. * * @param handler - Callback receiving the key, namespace, and locale * * @example * onMissingTranslation((key, ns, locale) => { * console.warn(`Missing: ${ns}:${key} [${locale}]`); * }); */ export declare function onMissingTranslation(handler: MissingTranslationHandler | null): void; export {};