如何解决带有动态变量的 Angular $localize 国际化使用自定义 ID
如何将动态变量放入 Angular 本地化的翻译中?我的团队在以下(高度简化的)安排下使用 $localize 和自定义 ID。
travel.component.ts
export class TravelComponent {
totalCountries = 3; // called from API
description = $localize`:@@VISITED: User visited ${totalCountries} countries.`;
}
travel.component.html
<div i18n>{{ description }}</div>
translations.component.html
<pre i18n="@@VISITED">User visited XXXXX countries.</pre>
如何将 XXXXX
替换为 totalCountries
?
尝试失败
使用 this resource,我尝试过:
travel.component.ts
description = $localize`:@@VISITED: User visited ${totalCountries}:totalVisits: countries.`;
travel.component.html
<pre i18n="@@VISITED">User visited <x id="totalVisits"/> countries.</pre>
但是,我收到错误 Errors parsing template: Only void and foreign elements can be self closed "x"
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。