Skip to content

Commit

Permalink
🐛 bug(fallback): fix fallback locale issue
Browse files Browse the repository at this point in the history
close #174
  • Loading branch information
kazupon committed Jun 12, 2017
1 parent b98c669 commit d9ceddc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
// component local i18n
if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
options.i18n.root = this.$root.$i18n
options.i18n.fallbackLocale = this.$root.$i18n.fallbackLocale
options.i18n.silentTranslationWarn = this.$root.$i18n.silentTranslationWarn
}

Expand Down
40 changes: 40 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,44 @@ describe('issues', () => {
}).then(done)
})
})

describe('#174', () => {
it('should be fallback', done => {
vm = new Vue({
i18n: new VueI18n({
locale: 'en',
fallbackLocale: 'ja',
messages: {
en: {},
ja: { msg: 'メッセージ' }
}
}),
components: {
comp: {
i18n: {
messages: {
en: {},
ja: { hello: 'こんにちは' }
}
},
render (h) {
return h('div', [
h('p', { ref: 'el1' }, [this.$t('hello')]),
h('p', { ref: 'el2' }, [this.$t('msg')])
])
}
}
},
render (h) {
return h('div', [h('comp', { ref: 'comp' })])
}
}).$mount()
const el1 = vm.$refs.comp.$refs.el1
const el2 = vm.$refs.comp.$refs.el2
nextTick(() => {
assert.equal(el1.textContent, 'こんにちは')
assert.equal(el2.textContent, 'メッセージ')
}).then(done)
})
})
})

0 comments on commit d9ceddc

Please sign in to comment.