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

Commit eeaf936

Browse files
committed
🐛 bug(translate): fix underscore named argument translate issue
1 parent d317165 commit eeaf936

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* https://github.com/Matt-Esch/string-template/index.js
55
*/
66

7-
const RE_NARGS = /(%|)\{([0-9a-zA-Z]+)\}/g
7+
const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g
88

99

1010
/**

test/specs/fixture/locales.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default {
1010
},
1111
'hello world': 'Hello World',
1212
'Hello {0}': 'Hello {0}',
13-
'continue-with-new-account': 'continue with new account'
13+
'continue-with-new-account': 'continue with new account',
14+
underscore: '{hello_msg} world'
1415
},
1516
ja: {
1617
message: {

test/specs/issues.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import locales from './fixture/locales'
55

66
describe('issues', () => {
77
let vm
8+
beforeEach(() => {
9+
vm = new Vue()
10+
})
11+
812

913
describe('#24', () => {
10-
beforeEach(() => {
11-
vm = new Vue()
14+
it('should be translated', () => {
15+
assert(vm.$t('continue-with-new-account') === locales[Vue.config.lang]['continue-with-new-account'])
1216
})
17+
})
1318

19+
describe('#35', () => {
1420
it('should be translated', () => {
15-
assert(vm.$t('continue-with-new-account') === locales[Vue.config.lang]['continue-with-new-account'])
21+
assert(vm.$t('underscore', { hello_msg: 'hello' }) === 'hello world')
1622
})
1723
})
1824
})

0 commit comments

Comments
 (0)