/** * 国际化资源加载工具 - 对标 @gulibs/vgrove-i18n 优化版 */ /** * 资源加载器配置接口 - 与 vgrove-i18n 兼容 */ export interface I18nLoaderConfig { /** 翻译资源基础路径 */ basePath?: string; /** 支持的文件扩展名 */ extensions?: string[]; /** 语言代码提取模式 */ localePattern?: 'directory' | 'filename'; /** 默认语言代码 */ defaultLocale?: string; /** 缓存时间 (毫秒) */ cacheTime?: number; /** 是否启用缓存 */ cache?: boolean; /** 是否启用调试模式 */ debug?: boolean; /** 加载回调 */ onLoad?: (locale: string, data: Record) => void; /** 错误回调 */ onError?: (locale: string, error: Error) => void; /** 自定义获取翻译资源函数 */ fetchResources?: (locale: string, path: string) => Promise>; } /** * 资源加载器接口 - 与 vite-plugin-i18n 生成的接口兼容 */ export interface I18nResourceLoader { /** 加载指定语言的资源 */ loadResources: (locale: string) => Promise>; /** 预加载多个语言的资源 */ preloadResources: (locales: string[]) => Promise>>; /** 清除缓存 */ clearCache: (locale?: string) => void; /** 获取配置 */ getConfig: () => I18nLoaderConfig; /** 获取所有可用的键 */ getAvailableKeys?: () => string[]; /** 检查键是否存在 */ hasKey?: (key: string) => boolean; /** 获取命名空间资源 */ getNamespaceResources?: (locale: string, namespace: string) => Record | undefined; } /** * 虚拟模块加载器 - 优先使用 vite-plugin-i18n 生成的资源 */ export declare class ViteI18nLoader implements I18nResourceLoader { private config; private cache; private virtualModuleResources?; private virtualModuleKeys?; private virtualModuleSupportedLocales?; private virtualModuleConfig?; constructor(config?: I18nLoaderConfig); /** * 初始化虚拟模块,加载静态资源 */ private initVirtualModule; /** * 获取虚拟模块资源(供外部直接访问) */ getVirtualModuleResources(): Record> | undefined; /** * 获取虚拟模块配置 */ getVirtualModuleConfig(): { supportedLocales: string[]; basePath: string; localePattern: 'directory' | 'filename'; } | undefined; /** * 加载指定语言的翻译资源 */ loadResources(locale: string): Promise>; /** * 动态加载资源(当虚拟模块不可用时的回退方案) */ private dynamicLoadResources; /** * 预加载多个语言的翻译资源 */ preloadResources(locales: string[]): Promise>>; /** * 清除资源缓存 */ clearCache(locale?: string): void; /** * 获取配置 */ getConfig(): I18nLoaderConfig; /** * 获取所有可用的键(来自虚拟模块) */ getAvailableKeys(): string[]; /** * 检查键是否存在 */ hasKey(key: string): boolean; /** * 获取命名空间资源 */ getNamespaceResources(locale: string, namespace: string): Record | undefined; /** * 获取支持的语言列表 */ getSupportedLocales(): string[]; /** * 检查是否使用虚拟模块 */ isUsingVirtualModule(): boolean; } /** * 创建优化的资源加载器 */ export declare function createI18nLoader(config?: I18nLoaderConfig): I18nResourceLoader; //# sourceMappingURL=i18n-loader.d.ts.map