airyland / vux

Mobile UI Components based on Vue & WeUI
https://vux.li
MIT License
17.59k stars 3.71k forks source link

[vue-i18n] Fall back to translate the keypath 'depo.method' with 'en-US' locale. #2833

Open richdavid opened 6 years ago

richdavid commented 6 years ago

[vue-i18n] Fall back to translate the keypath 'depo.method' with 'en-US' locale.

locale zh-CN

image

const i18n = new VueI18n({ locale: cookie.get('lang'), messages: { 'zh-CN': require('./common/lang/cn'), // 中文语言包 'en-US': require('./common/lang/en') // 英文语言包 } })

mounted () {

  if (cookie.get('lang') === '0') {
    this.locale = 'en-US'
    this.lang = '中文'
  } else {
    this.locale = 'zh-CN'
    this.lang = 'ENG'
  }
  cookie.set('lang', this.locale === 'en-US' ? '0' : '1', 1)
},

watch: { locale (val) { this.$i18n.locale = val console.log('locale', val) } }, locale

本地有cookie, 为1,函数是 lang=1的时候,locale是中文,但是它还是返回到用英文。

bigkrys commented 2 years ago

你好,请问解决了吗