- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Angular.io 对 i18n 标签的描述如下:
The Angular i18n attribute marks translatable content. Place it on every element tag whose fixed text is to be translated.
所以我的问题是这样的。如果我有一个内容是动态的元素怎么办?以显示 Assets 列表的下表为例。 “描述”栏在某些情况下需要使用英语,在某些情况下需要使用其他语言。
<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>
...但我错了。有什么建议吗?
最佳答案
首先,i18n 值是一个 ID,因此它始终是静态的。
其次,就翻译内容的变化而言,我唯一的成功是使用 NgSwitch 的解决方法。在模板中。
在此示例中,thingStatus
是您的变量,其可能的值为“good”、“bad”和“unknown”。所有这些都将是一个单独的翻译项目,具有自己的 i18n ID 值。
显然,如果 thingStatus
可能有无法控制的可能性,这将失败。
<div [ngSwitch]="thingStatus">
<p *ngSwitchCase="good" i18n="status_good>Good</p>
<p *ngSwitchCase="bad" i18n="status_bad>Bad</p>
<p *ngSwitchCase="unknown" i18n="status_unknown>Unknown</p>
</div>
关于javascript - Angular中动态内容的国际化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47232211/
我有一个 Java 字符串,但在处理时遇到了问题。我有一个字符串 s,它的值为丞(我随机选择的一个汉字,我不会说中文)。如果我打电话 String t = new String(s.getBytes(
在Qt中,所有的输入部件和文本绘制方式对Qt支持的所有语言都提供了内置的支持。Qt内置的字体引擎可以在同一时间正确而且精细地绘制不同的文本,这些文本可以包含来自众多不同书写系统的字符。如果想了解更多的
如何实现字段标签、帮助文本等的国际化支持。字段的标准乘法似乎不起作用例如文档中给出的用于创建联系表单的示例。我尝试为其他语言添加额外的字段(文档中描述的第一种方法) from django.db
是否有可能当我在操作类中使用“getText(”keyName”); 时,我可以指定仅从 ENGLISH 资源包中选择值。因为我只想将此值用于日志记录目的。 任何想法我怎么能做到这一点? BR 标准委
我有一些关于 GWT 的国际化解决方法的问题。 1) 处理直接写入 ui.xml 文件的静态文本的最佳方式是什么? 目前,我正在使用 Messages-Interface 来翻译 Java 生成的文本
我在 Symfony 2 中遇到了一个奇怪的翻译问题。 这是我的config.yml imports: - { resource: parameters.yml } - { resou
对于我的大部分应用程序,我可以使用 https://developers.google.com/web-toolkit/doc/latest/DevGuideI18n 中列出的推荐国际化技术。 (主要
我使用 Android Studio 创建了一个新的 Flutter 项目。我正在使用null-safety,并且正在物理设备上运行应用程序,但代码生成无法正常工作,没有flutter_gen.dar
这里是菜鸟。 我正在尝试对基于命令行的程序实现国际化。以下是 java 国际化路径中可用的内容。 import java.util.*; public class I18NSample { s
我使用 Android Studio 创建了一个新的 Flutter 项目。我正在使用null-safety,并且正在物理设备上运行应用程序,但代码生成无法正常工作,没有flutter_gen.dar
我正在开发一个需要多语言的应用程序。 我正在尝试关注 this国际化教程。但是,当我尝试“使用基本国际化”时, View 中没有列出我的 Storyboard。 我正在使用 XCode 4.6.3 我
我住在印度(有超过20种语言)我正在尝试在网站中实现java国际化。 但是在 Locale.getAvailableLocales() 中,本地语言不可用。我的情况是否可以实现国际化? 如果可能的话字
我有以下 SDN 4 实体: 决策、特征和值: @NodeEntity public class Value { private final static String SET_FOR = "
关于MySql,是否有支持所有或绝大多数语言的字符集? 最佳答案 统一码。它有几种编码:UTF-8、UTF-16 和 UTF-32。 来自 http://en.wikipedia.org/wiki/U
我目前正在使用 Vuepress。但是我想要在我的 Vuepress 站点中使用多种语言。经过 3 天的挣扎,我决定把我的问题放在这里。 (是的,我查看了 Vuepress 文档:https://vu
我需要返回一个 strftime() 调用,该调用使用与我本地机器/操作系统上设置的语言不同的语言。是否可以选择返回语言? 最佳答案 对于可靠的 i18n/L10N,可由必须在同一运行中提供不同本地化
我有一些按钮,按下它们后我想播放一些音频。按钮的名称是音频文件的名称 private func playAudio(title : String){ audioPlayer = AVAudio
如何更改 HTML5 的消息(或者它会根据浏览器的语言自动更改?) 例如: E-mail: 当我在 Opera 运行此代码(来自 W3schools)
我发现很多关于 url schemes 的话题,最常见的是: www.mysite.com/fr/products www.mysite.com/en/products www.mysite.com/
在 Android WebView 中处理国际化/本地化的最佳方式是什么。理想情况下,我想访问以下位置的所有字符串资源: res/values/strings.xmlres/values-de/str
我是一名优秀的程序员,十分优秀!