Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit 35c268a

Browse files
committed
🐛 bug(extend): fix array local
Closes #91 Closes #59
1 parent e0adbc5 commit 35c268a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/extend.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function (Vue) {
4141
if (!locale) { return null }
4242

4343
let val = getValue(locale, key)
44+
if (Array.isArray(val)) { return val }
4445
if (isNil(val)) { val = locale[key] }
4546
if (isNil(val)) { return null }
4647

test/specs/fixture/locales.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export default {
3636
[
3737
'this is nested array error 1'
3838
]
39-
]
39+
],
40+
issues: {
41+
array_bugs: ['bug1', 'bug2']
42+
}
4043
},
4144
ja: {
4245
message: {
@@ -66,6 +69,9 @@ export default {
6669
[
6770
'これはネストされた配列のエラー1です。'
6871
]
69-
]
72+
],
73+
issues: {
74+
array_bugs: ['バグ1', 'バグ2']
75+
}
7076
}
7177
}

test/specs/issues.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@ describe('issues', () => {
4545
)
4646
})
4747
})
48+
49+
describe('#91, #51', () => {
50+
it('should be translated', () => {
51+
const arrayLocales = locales[Vue.config.lang].issues.array_bugs
52+
for (let i = 0; i < arrayLocales.length; i++) {
53+
const item = vm.$t('issues.array_bugs')[i]
54+
assert.equal(item, arrayLocales[i])
55+
}
56+
})
57+
})
4858
})

0 commit comments

Comments
 (0)