update 基本完成国际化

This commit is contained in:
2022-09-02 14:09:41 +08:00
parent 12556886b9
commit 076eaa5f2a
15 changed files with 503 additions and 85 deletions

View File

@@ -21,11 +21,13 @@ export const messages = {
}
export function getLanguage() {
const chooseLanguage = Cookies.get('language')
if (chooseLanguage) return chooseLanguage
if (Cookies.get('language')) {
return Cookies.get('language')
}
// if has not choose language
const language = (navigator.language || navigator.browserLanguage).toLowerCase()
const language = (navigator.language || navigator.browserLanguage)
const locales = Object.keys(messages)
for (const locale of locales) {
if (language.indexOf(locale) > -1) {
@@ -33,8 +35,9 @@ export function getLanguage() {
return locale
}
}
Cookies.set('language', 'zh-CN')
return 'zh-CN'
Cookies.set('language', 'en')
return 'en'
}
export default new VueI18n({