【问题标题】: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>

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

非常感谢。

【问题讨论】:

标签: angular internationalization


【解决方案1】:

您好,我可以为您推荐一个很棒的 ng2-translate 库,它非常易于使用。 https://github.com/ocombe/ng2-translate

【讨论】:

    【解决方案2】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多