mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-07 02:37:26 +08:00
[F] FIX i18n.ts type
This commit is contained in:
@@ -57,7 +57,7 @@ const allI18n: { en: LocalizationMessages; zh: LocalizationMessages } = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const msgs: { [index: string]: LocalizationMessages} = {
|
const msgs: { [lang: string]: LocalizationMessages} = {
|
||||||
en: allI18n.en,
|
en: allI18n.en,
|
||||||
zh: allI18n.zh
|
zh: allI18n.zh
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ if (navigator.language.startsWith('zh')) {
|
|||||||
lang = 'zh'
|
lang = 'zh'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function t(key: keyof typeof allI18n.zh |keyof typeof allI18n.en, variables?: { [index: string]: string }) {
|
export function t(key: keyof LocalizationMessages, variables?: { [index: string]: string }) {
|
||||||
if (variables) {
|
if (variables) {
|
||||||
return msgs[lang][key].replace(/\${(.*?)}/g, (_:string, v: string | number) => variables[v])
|
return msgs[lang][key].replace(/\${(.*?)}/g, (_:string, v: string | number) => variables[v])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user