这可能吗?说我有以下要翻译的文字:
<p>You currently have <span class="bold">{{rewards?.points}}</span> points worth <span class="bold">{{rewards?.amount | currency}}</span> statement credit.</p>
我希望这个文本可以翻译,但有两件事让我失望 - 如何注入变量点/数量以及如何保留粗体span标签。
来自我的en-US.json文件:
"statement": "You currently have {{points_param}} points worth {{credit_param}} statement credit."
如果我想对点数/金额使用静态值,则执行以下操作,但这不会保留粗体样式或允许变量值。
<p [innerHTML]="'redeem.statement' | translate:{points_param:'50',credit_param:'100'}"></p>
答案 0 :(得分:1)
试试这段代码:
en-US.json文件:
"statement": "You currently have <span class='bold'>{{points_param}}</span> points worth <span class='bold'>{{credit_param}} </span> statement credit."
在组件HTML文件中:
<p [innerHTML]="'redeem.statement' | translate:{points_param:'50',credit_param:'100' | currency }"></p>
确保为span粗体类添加CSS。