From 469edd916ce1d0a8e4b33f5831ebd8b27e0551fa Mon Sep 17 00:00:00 2001 From: Yanis Benson Date: Sun, 10 Feb 2019 17:29:12 +0300 Subject: [PATCH] :bug: bug(index): fixed #478 (#518) by @stroncium * fixed #478 * links to links test --- src/index.js | 2 +- test/unit/fixture/index.js | 3 +++ test/unit/issues.test.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 42c24bcfe..1f814896e 100644 --- a/src/index.js +++ b/src/index.js @@ -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) diff --git a/test/unit/fixture/index.js b/test/unit/fixture/index.js index 949863ee8..14a144f63 100644 --- a/test/unit/fixture/index.js +++ b/test/unit/fixture/index.js @@ -2,6 +2,7 @@ export default { en: { message: { hello: 'the world', + helloName: 'Hello {name}', hoge: 'hoge', empty: '', format: { @@ -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?', diff --git a/test/unit/issues.test.js b/test/unit/issues.test.js index 151c6bc3b..4789c169e 100644 --- a/test/unit/issues.test.js +++ b/test/unit/issues.test.js @@ -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}') + }) + }) })