Skip to content

Commit c805080

Browse files
perf: The assistant's language follows the browser's default language
1 parent 8a3b5fd commit c805080

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

frontend/src/i18n/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import koKR from './ko-KR.json'
55
import elementEnLocale from 'element-plus-secondary/es/locale/lang/en'
66
import elementZhLocale from 'element-plus-secondary/es/locale/lang/zh-cn'
77
import { useCache } from '@/utils/useCache'
8+
import { getBrowserLocale } from '@/utils/utils'
89

910
const elementKoLocale = elementEnLocale
1011
const { wsCache } = useCache()
1112

1213
const getDefaultLocale = () => {
13-
const language = wsCache.get('user.language')
14-
return language || 'zh-CN'
14+
return wsCache.get('user.language') || getBrowserLocale() || 'zh-CN'
1515
}
1616

1717
const messages = {
@@ -32,7 +32,7 @@ const messages = {
3232
export const i18n = createI18n({
3333
legacy: false,
3434
locale: getDefaultLocale(),
35-
fallbackLocale: 'en',
35+
fallbackLocale: 'zh-CN',
3636
globalInjection: true,
3737
messages,
3838
})
@@ -46,4 +46,4 @@ const elementLocales = {
4646
export const getElementLocale = () => {
4747
const locale = i18n.global.locale.value as keyof typeof elementLocales
4848
return elementLocales[locale] ?? elementEnLocale
49-
}
49+
}

0 commit comments

Comments
 (0)