// i18n 国际化配置 // 这是一个简化的 i18n 实现,用于支持多语言切换 // 语言资源 const messages: UTSJSONObject = new UTSJSONObject() // 默认语言 const defaultLocale = 'zh-CN' // 当前语言(响应式) let currentLocale = defaultLocale // 翻译函数 function t(key: string, values: UTSJSONObject | null = null, locale: string | null = null): string { const targetLocale = locale ?? currentLocale // 这里应该从 messages 中获取翻译,简化实现直接返回 key // 实际项目中应该加载语言资源文件 return key } // 创建响应式 locale 对象 const localeObj = { get value(): string { return currentLocale }, set value(newLocale: string) { currentLocale = newLocale } } // 导出 i18n 对象(兼容 Vue I18n 的 API) const i18nInstance = { global: { t: t, locale: localeObj } } export default i18nInstance