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

Commit e15ead4

Browse files
committed
🐛 bug(path): fix nested key translation
Closes #97
1 parent 4cac8b9 commit e15ead4

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/path.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ pathStateMachine[IN_PATH] = {
4242

4343
pathStateMachine[BEFORE_IDENT] = {
4444
'ws': [BEFORE_IDENT],
45-
'ident': [IN_IDENT, APPEND]
45+
'ident': [IN_IDENT, APPEND],
46+
'0': [IN_IDENT, APPEND],
47+
'number': [IN_IDENT, APPEND]
4648
}
4749

4850
pathStateMachine[IN_IDENT] = {

test/specs/fixture/locales.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default {
1313
link_end: 'This is a linked translation to @:message.hello',
1414
link_within: 'Isn\'t @:message.hello we live in great?',
1515
link_multiple: 'Hello @:message.hoge!, isn\'t @:message.hello great?',
16-
'hyphen-locale': 'hello hyphen'
16+
'hyphen-locale': 'hello hyphen',
17+
'1234': 'Number-based keys are found',
18+
'1mixedKey': 'Mixed keys are not found.'
1719
},
1820
'hello world': 'Hello World',
1921
'Hello {0}': 'Hello {0}',
@@ -51,7 +53,9 @@ export default {
5153
list: 'こんにちは {0}, ごきげんいかが?'
5254
},
5355
fallback1: 'これはフォールバック',
54-
'hyphen-locale': 'こんにちは、ハイフン'
56+
'hyphen-locale': 'こんにちは、ハイフン',
57+
'1234': '数字ベースのキーは見つかりませんでした。',
58+
'1mixedKey': 'ミックスされたキーは見つかりませんでした。'
5559
},
5660
plurals: {
5761
car: 'ザ・ワールド | これはフォールバック',

test/specs/issues.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,17 @@ describe('issues', () => {
5555
}
5656
})
5757
})
58+
59+
describe('#97', () => {
60+
it('should be translated', () => {
61+
assert.equal(
62+
vm.$t('message.1234'),
63+
locales[Vue.config.lang]['message']['1234']
64+
)
65+
assert.equal(
66+
vm.$t('message.1mixedKey'),
67+
locales[Vue.config.lang]['message']['1mixedKey']
68+
)
69+
})
70+
})
5871
})

0 commit comments

Comments
 (0)