UNPKG

wuchale

Version:

Protobuf-like i18n from normal code

30 lines 1.3 kB
import { type CatalogModule, Runtime } from '../runtime.js'; export type LoaderFunc = (loadID: string, locale: string) => CatalogModule | Promise<CatalogModule>; export type CatalogCollection = { get: (loadID: string) => CatalogModule; set: (loadID: string, catalog: CatalogModule) => void; }; export type LoaderState = { load: LoaderFunc; loadIDs: string[]; collection: CatalogCollection; loadedLocale?: string; }; export declare function defaultCollection(store: Record<string, CatalogModule>): CatalogCollection; /** * - `key` is a unique identifier for the group * - `loadIDs` and `load` MUST be imported from the loader virtual modules or proxies. */ export declare function registerLoaders(key: string, load: LoaderFunc, loadIDs: string[], collection?: CatalogCollection): (fileID: string) => Runtime; /** * Loads catalogs using registered async loaders. * Can be called anywhere you want to set the locale. */ export declare function loadLocale(locale: string, key?: string): Promise<void>; /** * Loads catalogs using registered sync loaders. * Can be called anywhere you want to set the locale. * The loadCatalog function should be from a sync proxy. */ export declare function loadLocaleSync(locale: string, key?: string): void; //# sourceMappingURL=index.d.ts.map