This commit is contained in:
Baobhan Sith
2025-05-10 00:00:31 +08:00
parent 36afe3d5c2
commit c36e961426
29 changed files with 2268 additions and 41 deletions
+6 -1
View File
@@ -26,7 +26,12 @@ if (availableLocales.length === 0) {
// 类型推断 (基于第一个加载的语言文件,假设所有文件结构一致)
// 如果没有加载到文件,则使用空对象作为 fallback,避免运行时错误
// 使用更通用的类型 Record<string, any> 来避免动态索引的类型推断问题
type MessageSchema = Record<string, any>;
// 尝试一个更具体的类型来帮助 TypeScript 推断,以解决深层实例化问题
// 这允许嵌套的翻译键,例如 'parent.child.grandchild'
interface RecursiveStringRecord {
[key: string]: string | RecursiveStringRecord;
}
type MessageSchema = RecursiveStringRecord;
// 定义默认语言 (优先使用 'en-US',如果不存在则使用第一个找到的语言)
export const defaultLng = availableLocales.includes('en-US') ? 'en-US' : availableLocales[0] || 'en-US'; // 更新为 en-US