【问题标题】:How to translate attributes with the Angular 2 ng-xi18n tool如何使用 Angular 2 ng-xi18n 工具翻译属性
【发布时间】:2017-04-05 05:03:55
【问题描述】:
标签的文本可以这样设置翻译:
<h1 i18n>Welcome</h1>
placeholder 或 label 等属性是如何设置的?
<input type="text" placeholder="Type your name" /> 或
<button type="submit" label="Send data"></button>(库primeng需要这样设置按钮的标签)
非常感谢。
【问题讨论】:
标签:
angular
internationalization
【解决方案2】:
要翻译标记placeholder 属性进行翻译,您可以添加i18n-placeholder 属性,如下所示:
<input type="text" i18n-placeholder="@@type-your-name" placeholder="Type your name" />
对于其他属性,它的工作方式相同:i18n-x,其中x 是要翻译的属性的名称。
您也可以在 here 的 Angular i18n 指南中找到答案。