Skip to content

Commit 879cee6

Browse files
committed
fix language en translation
1 parent d6d6d25 commit 879cee6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/i18n.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { createI18n } from 'vue-i18n'
22
import zhCN from './locales/zh-CN.json'
33

4-
const messages = {
5-
'en': Object.fromEntries(Object.keys(zhCN).map(key => [key, key])),
4+
function replaceLeaves(object: Record<string, any>): Record<string, any> {
5+
const result: Record<string, any> = {}
6+
for (const [key, value] of Object.entries(object)) {
7+
result[key] = typeof value === 'object' ? replaceLeaves(value) : key
8+
}
9+
return result
10+
}
11+
12+
const messages: Record<string, any> = {
13+
'en': replaceLeaves(zhCN),
614
'zh-CN': zhCN,
715
}
816

@@ -18,6 +26,7 @@ export function getLocale(messages: { [key: string]: any }) {
1826
return 'zh-CN'
1927
}
2028
}
29+
return 'en'
2130
}
2231

2332
const i18n = createI18n({

0 commit comments

Comments
 (0)