diff --git a/src/index.js b/src/index.js index 3afe15309..aa00879e0 100644 --- a/src/index.js +++ b/src/index.js @@ -199,7 +199,7 @@ export default class VueI18n { if (!message) { return null } const pathRet: PathValue = this._path.getPathValue(message, key) - if (Array.isArray(pathRet)) { return pathRet } + if (Array.isArray(pathRet) || isPlainObject(pathRet)) { return pathRet } let ret: mixed if (isNull(pathRet)) { diff --git a/test/unit/basic.test.js b/test/unit/basic.test.js index 13bd94a01..446de8be9 100644 --- a/test/unit/basic.test.js +++ b/test/unit/basic.test.js @@ -104,6 +104,12 @@ describe('basic', () => { }) }) + describe('parent object', () => { + it('should be translated', () => { + assert.equal(i18n.t('errors[1]'), messages.en.errors[1]) + }) + }) + describe('array', () => { it('should be translated', () => { assert.equal(i18n.t('errors[2][0]'), messages.en.errors[2][0]) @@ -403,7 +409,6 @@ describe('basic', () => { }) }) - describe('$tc', () => { describe('en locale', () => { it('should translate plural english', () => {