/** * dsh-widgets i18n — SHELL dictionary + locale-service wiring. * * Architecture (ARCH-001): this file owns ONLY the shell/UI strings (rails, * settings pages, market chrome, generic labels). Per-widget strings live in * each widget unit's `manifest.json` (merged by the registry generator into * `generated.registry.ts` → `WIDGET_LOCALES`) and are handed in at apply() * time via `installLocale(api, WIDGET_LOCALES)` / `setExtraLocales(...)`. * A widget unit NEVER edits this file — it ships its own locale. * * Preferred channel is the official `locale` service (`ctx.get('locale')`, * provided by @deepseek-ai/dsh-client-locale): its `bind(ns)` returns a * translate function that reads the ACTIVE locale at call time, so switching * Settings → Language takes effect on every re-render. Fallback (locale * service absent from the composition) stays self-contained: the built-in * zh/en dictionaries decided by the same detection chain the product uses * (localStorage 'dsh-language' → → navigator.language). * * `onLocaleChange` lets the widget rail subscribe to locale switches so the * always-mounted surfaces re-render immediately (official shell re-renders * only settings content). */ /** The narrow slice of LocaleRuntime we consume (untyped: no hard dep). */ export interface LocaleApi { /** Register one locale's dictionary for the widget namespace. */ register?: (ns: string, locale: string, dict: Record) => () => void; bind?: (ns: string) => (key: string, params?: Record) => string; subscribe?: (fn: () => void) => () => void; } export type T = (key: string, params?: Record) => string; /** Per-widget merged dictionaries (from the registry generator). */ export interface WidgetLocales { zh?: Record; en?: Record; } /** Feed the per-widget locale maps into the translation path (called once at * apply() with `WIDGET_LOCALES` from the generated registry). The widget * dictionaries are merged over the shell dictionaries at READ time, so both * the official-service registration and the built-in fallback see them. */ export declare function setExtraLocales(extra: WidgetLocales): void; /** Feed the official locale service (called from apply). Registers the merged * zh/en dictionaries for this namespace, then binds the translate function so * `t()` resolves through the runtime's ACTIVE locale on every call. Returns a * disposer that unregisters everything. */ export declare function installLocale(api: LocaleApi | undefined, widgetLocales?: WidgetLocales): () => void; /** Subscribe to locale switches (per-fiber cleanup via the returned disposer). */ export declare function onLocaleChange(fn: () => void): () => void; /** Translate a dictionary key; prefers the official locale translation. */ export declare function t(key: string, params?: Record): string; /** Translate with multiple params shorthand. */ export declare function tf(key: string, params: Record): string;