diff --git a/src/extend.js b/src/extend.js index 750b6a165..2cf66e034 100644 --- a/src/extend.js +++ b/src/extend.js @@ -13,6 +13,6 @@ export default function extend (Vue: any): void { Vue.prototype.$te = function (key: Path, locale?: Locale): boolean { const i18n = this.$i18n - return i18n._te(key, i18n.locale, i18n.messages, [locale]) + return i18n._te(key, i18n.locale, i18n.messages, locale) } } diff --git a/src/index.js b/src/index.js index ea0342a87..0f574bc6e 100644 --- a/src/index.js +++ b/src/index.js @@ -242,7 +242,7 @@ export default class VueI18n { } te (key: Path, locale?: Locale): boolean { - return this._te(key, this.locale, this.messages, [locale]) + return this._te(key, this.locale, this.messages, locale) } getLocaleMessage (locale: Locale): LocaleMessage { diff --git a/test/unit/basic.test.js b/test/unit/basic.test.js index 9327307a8..0cbe75ec5 100644 --- a/test/unit/basic.test.js +++ b/test/unit/basic.test.js @@ -280,6 +280,10 @@ describe('basic', () => { it('should return false', () => { assert(i18n.te('message.hallo') === false) }) + + it('should return false with locale', () => { + assert(i18n.te('message.hello', 'xx') === false) + }) }) }) @@ -518,6 +522,11 @@ describe('basic', () => { const vm = new Vue({ i18n }) assert(vm.$te('message.hallo') === false) }) + + it('should return false with locale', () => { + const vm = new Vue({ i18n }) + assert(vm.$te('message.hello', 'xx') === false) + }) }) })