我想把這句話翻譯成i18n
Select <b>branch(s)</b> you want to send selected product
after selecting Branch Click on submit
如您所見,上面句子中的一個單詞在<b>標簽中。
我有這個解決方案,但我不確定這是不是最好的方法。
$t('part1') <b>$t('part2')</b> $t('part3')
那么,你知道更好的翻譯方法嗎?
uj5u.com熱心網友回復:
根據您的要求,我們必須翻譯包含 HTML 標簽的訊息/句子。
您在OP中提到的解決方案$t('part1') <b>$t('part2')</b> $t('part3')難以管理且復雜。i18n 您可以使用功能組件來避免它。例如:
您的語言 JSON 將如下所示:
const messages = {
en: {
info: 'Select {branchText} you want to send selected product after selecting Branch Click on submit.',
subText: 'branch(s)',
}
}
模板將如下所示:
<i18n path="info" tag="p">
<template v-slot:branchText>
<b>{{ $t('subText') }}</b>
</template>
</i18n>
希望這個答案會有所幫助!謝謝。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/414171.html
標籤:
上一篇:獲取子組件輸入資料到父組件,在Vue.js中收集到陣列?
下一篇:如何使用Vue.js將多個影像上傳到firebasev9存盤并獲取所有下載URL以在云Firestore資料庫中更新它
