【发布时间】:2017-11-10 22:39:01
【问题描述】:
Angular.io 对 i18n 标签的描述如下:
Angular i18n 属性标记可翻译内容。把它放在 每个要翻译其固定文本的元素标签。
所以我的问题是这样的。如果我有一个内容是动态的元素怎么办?例如下面这张显示资产列表的表格。 “描述”列在某些情况下需要是英语,在某些情况下需要使用其他语言。
<table class="asset-table">
<thead>
<tr>
<th i18n="@@alarm-list-timeon">Time On</th>
<th i18n="@@alarm-list-timeoff">Time Off</th>
<th i18n="@@alarm-list-asset">Asset</th>
<th i18n="@@alarm-list-description">Description</th>
</tr>
</thead>
<tbody *ngIf="showAssets">
<tr *ngFor="let asset of pageItems">
<td>{{asset.timeon}}</td>
<td>{{asset.timeoff}}</td>
<td>{{asset.assetlabel}}</td>
<td i18n>{{asset.description}}</td>
</tr>
</tbody>
</table>
我在想这样的事情:
<table class="asset-table">
<thead>
<tr>
<th i18n="@@alarm-list-timeon">Time On</th>
<th i18n="@@alarm-list-timeoff">Time Off</th>
<th i18n="@@alarm-list-asset">Asset</th>
<th i18n="@@alarm-list-description">Description</th>
</tr>
</thead>
<tbody *ngIf="showAssets">
<tr *ngFor="let asset of pageItems">
<td>{{asset.timeon}}</td>
<td>{{asset.timeoff}}</td>
<td>{{asset.assetlabel}}</td>
<td i18n="@@{{asset.description}}">{{asset.description}}</td>
</tr>
</tbody>
</table>
...但我错了。有什么建议吗?
【问题讨论】:
-
Angular i18n 是静态的,而不是动态的。
标签: javascript angular typescript internationalization angular-i18n