我使用的是vue-i18n
,我需要在中间翻译带有锚标记的句子。很明显,我想保留我的翻译html特定的标记,但如何最好地处理这个?vue-i18n翻译中html标签的最佳实践?
请看下面的例子:
This is a test sentence which cannot
<a href="https://example.com" class="test-class test-another-class">be split</a>
or it will not make sense
唯一的解决办法我能想出是:
{
"en": {
"example": "This is a test sentence which cannot {linkOpen}be split{linkClose} or it will not make sense"
}
}
,然后分量模板
<p v-html="$t('example', {
'linkOpen': `<a href="https://example/com" class="test-class test-another-class">`,
'linkClose: '</a>'
})
"></p>
不但是正是优雅...
编辑:我测试了这个,它并没有实际工作(不能把HTML中的参数),所以现在我真的没有想法!