Skip to content

Commit

Permalink
fix: Fix language switch error
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jul 12, 2020
1 parent 7bf9588 commit 720af76
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/core/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,12 @@ const getLocales = {

const init = async () => {
const supportLangs = globals.config.supportLangs.map(item => item.value)
const defaultLang = get(globals.user, 'lang')
if (defaultLang && cookie('lang') !== defaultLang) {
cookie('lang', defaultLang)
const userLang = get(globals.user, 'lang') || getBrowserLang()
if (userLang && cookie('lang') !== userLang) {
cookie('lang', userLang)
}

let lang = cookie('lang') || getBrowserLang()

if (!supportLangs.includes(lang)) {
lang = defaultLang
cookie('lang', lang)
}

if (lang === 'zh') {
if (userLang === 'zh') {
moment.locale('zh', {
relativeTime: {
s: '1秒',
Expand Down

0 comments on commit 720af76

Please sign in to comment.