如何使用Angular 2 ng-xi18n工具翻译属性

时间:2016-11-21 17:48:52

标签: angular internationalization

可以设置标签的文本进行翻译,如下所示: <h1 i18n>Welcome</h1>

如何设置占位符标签等属性? <input type="text" placeholder="Type your name" /><button type="submit" label="Send data"></button>(库primeng需要像这样设置按钮的标签)

非常感谢。

2 个答案:

答案 0 :(得分:3)

要翻译标记placeholder属性以进行翻译,您可以添加i18n-placeholder属性,如下所示:

<input type="text" i18n-placeholder="@@type-your-name" placeholder="Type your name" />

对于其他属性,它的工作方式相同:i18n-x,其中x是要翻译的属性的名称。

您也可以在找到here的Angular i18n指南中找到答案。

答案 1 :(得分:0)

您好我可以建议您使用ng2-translate它很容易使用。 https://github.com/ocombe/ng2-translate