简体   繁体   English

i18n:翻译一个单词是粗体的句子

[英]i18n : translate a sentence that one of words is bold

I want to translate this sentence in i18n我想把这句话翻译成i18n

Select <b>branch(s)</b> you want to send selected product
after selecting Branch Click on submit

As you can see, one word in above sentence is in <b> tag.如您所见,上面句子中的一个单词在<b>标记中。

I have this solution , But I am not sure is this is the best way to do or not.我有这个解决方案,但我不确定这是不是最好的方法。

$t('part1') <b>$t('part2')</b>  $t('part3')

so,do you know better way to translate this??所以,你知道更好翻译方法吗?

As per your requirement, we have to translate a message/sentence which contains HTML tag.根据您的要求,我们必须翻译包含 HTML 标签的消息/句子。

The solution $t('part1') <b>$t('part2')</b> $t('part3') you mentioned in OP is difficult to manage and complicated.您在OP中提到的解决方案$t('part1') <b>$t('part2')</b> $t('part3')难以管理且复杂。 You can avoid it using the i18n functional component .您可以使用i18n 功能组件来避免它。 For example :例如

Your language JSON will look like this:您的语言 JSON 将如下所示:

const messages = {
  en: {
    info: 'Select {branchText} you want to send selected product after selecting Branch Click on submit.',
    subText: 'branch(s)',
  }
}

Template will look like this:模板将如下所示:

<i18n path="info" tag="p">
  <template v-slot:branchText>
    <b>{{ $t('subText') }}</b>
  </template>
</i18n>

Hope this answer will help.希望这个答案会有所帮助。 Thanks.谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM