diff --git a/src/mixin.js b/src/mixin.js index e0b88c75c..2bcf2ebb4 100644 --- a/src/mixin.js +++ b/src/mixin.js @@ -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 } diff --git a/test/unit/issues.test.js b/test/unit/issues.test.js index 29ab810cb..9b14ac1af 100644 --- a/test/unit/issues.test.js +++ b/test/unit/issues.test.js @@ -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) + }) + }) })