From 07036cdea7048f1006bbd9c395eb4540ebbef22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Fri, 1 Apr 2022 15:41:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20i18n=E8=8E=B7=E5=8F=96=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E9=BB=98=E8=AE=A4=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/i18n.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index 61e1fb9be..05612ad34 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -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,