feat: i18n获取浏览器默认语言

This commit is contained in:
“huailei000” 2022-04-01 15:41:34 +08:00 committed by 老广
parent ec2674a956
commit 07036cdea7

View File

@ -7,11 +7,12 @@ import date from './date'
import VueCookie from 'vue-cookie'
Vue.use(VueI18n)
const cookieLang = VueCookie.get('django_language') || 'en'
const defaultLang = cookieLang.slice(0, 2)
const cookieLang = VueCookie.get('django_language')
const browserLang = navigator.systemLanguage || navigator.language
let lang = cookieLang || browserLang || 'zh'
lang = lang.slice(0, 2)
const i18n = new VueI18n({
locale: defaultLang,
locale: lang,
fallbackLocale: 'en',
silentFallbackWarn: true,
silentTranslationWarn: true,