【问题标题】:How to handle repeated texts in Angular i18n translation如何处理 Angular i18n 翻译中的重复文本
【发布时间】:2020-04-15 13:18:52
【问题描述】:

我正在使用 angular 8 和 i18n 将 Web 应用程序从英语翻译成荷兰语。所有的东西都工作正常。但我有一个场景,customer-details.component.htmlcustomer-form.component.htmlusers.component.html 中显示了一个元素<h4>Customer details</h4>。在users.component.html 中,相同的文本Customer details 出现了两次。我给i18n,比如i18n="Details of customer @@customerDetailsDetails"i18n="Details of customer @@customeFormsDetails"。现在在messages.xlf1 文件中,相同的文本Customer details 出现了三次以供翻译。我该如何处理这些类型的翻译重复?请帮帮我。

【问题讨论】:

    标签: angular internationalization angular8 angular-i18n


    【解决方案1】:

    只需在所有模板中提供相同的文本和@@id

    i18n="Details of customer @@customerDetails
    

    如果你给出不同的ID,翻译会出现多次,即使文本相同

    【讨论】:

      猜你喜欢
      • 2021-07-18
      • 2018-01-25
      • 2018-11-29
      • 2018-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      相关资源
      最近更新 更多