Skip to content

Commit

Permalink
⚡ improvement(index): support object localization (#311) by @manniL
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlexLichter authored and kazupon committed Mar 11, 2018
1 parent 8378859 commit 99e5006
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -403,7 +409,6 @@ describe('basic', () => {
})
})


describe('$tc', () => {
describe('en locale', () => {
it('should translate plural english', () => {
Expand Down

0 comments on commit 99e5006

Please sign in to comment.