Skip to content

Commit

Permalink
🐛 bug(index): fixed #478 (#518) by @stroncium
Browse files Browse the repository at this point in the history
* fixed #478

* links to links test
  • Loading branch information
stroncium authored and kazupon committed Feb 10, 2019
1 parent 58a3377 commit 469edd9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default class VueI18n {

// Check for the existence of links within the translated string
if (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0) {
ret = this._link(locale, message, ret, host, interpolateMode, values, visitedLinkStack)
ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack)
}

return this._render(ret, interpolateMode, values, key)
Expand Down
3 changes: 3 additions & 0 deletions test/unit/fixture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
en: {
message: {
hello: 'the world',
helloName: 'Hello {name}',
hoge: 'hoge',
empty: '',
format: {
Expand All @@ -10,6 +11,8 @@ export default {
},
fallback: 'this is fallback',
link: '@:message.hello',
linkHelloName: '@:message.helloName',
linkLinkHelloName: '@:message.linkHelloName',
linkEnd: 'This is a linked translation to @:message.hello',
linkWithin: 'Isn\'t @:message.hello we live in great?',
linkMultiple: 'Hello @:message.hoge!, isn\'t @:message.hello great?',
Expand Down
15 changes: 15 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,19 @@ describe('issues', () => {
assert(i18n.t(testPath), 'Hello!')
})
})

describe('#478', () => {
it('should be translated', () => {
const res = vm.$t('message.linkHelloName', { name: 'World {text}' })
assert.strictEqual(res, 'Hello World {text}')
})
it('should be translated', () => {
const res = vm.$t('message.linkHelloName', { name: 'World {text}', text: 'something' })
assert.strictEqual(res, 'Hello World {text}')
})
it('should be translated', () => {
const res = vm.$t('message.linkLinkHelloName', { name: 'World {text}', text: 'something' })
assert.strictEqual(res, 'Hello World {text}')
})
})
})

0 comments on commit 469edd9

Please sign in to comment.