Skip to content

Commit

Permalink
🐛 bug(extend): fix array local
Browse files Browse the repository at this point in the history
Closes #91
Closes #51
  • Loading branch information
kazupon committed Nov 24, 2016
1 parent e0adbc5 commit eacfbca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function (Vue) {
if (!locale) { return null }

let val = getValue(locale, key)
if (Array.isArray(val)) { return val }
if (isNil(val)) { val = locale[key] }
if (isNil(val)) { return null }

Expand Down
10 changes: 8 additions & 2 deletions test/specs/fixture/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export default {
[
'this is nested array error 1'
]
]
],
issues: {
array_bugs: ['bug1', 'bug2']
}
},
ja: {
message: {
Expand Down Expand Up @@ -66,6 +69,9 @@ export default {
[
'これはネストされた配列のエラー1です。'
]
]
],
issues: {
array_bugs: ['バグ1', 'バグ2']
}
}
}
10 changes: 10 additions & 0 deletions test/specs/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ describe('issues', () => {
)
})
})

describe('#91, #51', () => {
it('should be translated', () => {
const arrayLocales = locales[Vue.config.lang].issues.array_bugs
for (let i = 0; i < arrayLocales.length; i++) {
const item = vm.$t('issues.array_bugs')[i]
assert.equal(item, arrayLocales[i])
}
})
})
})

0 comments on commit eacfbca

Please sign in to comment.