i18n 在 Angular 代码的源标记中生成带有空格的 xlf

问题描述 投票:0回答:1

我在我的 Angular 项目中使用 i18n 进行本地化。我遇到一个问题,其中存在重复的文本条目,但间距不同(字符串开头/结尾处有空格。

  <trans-unit id="5983969941473094568" datatype="html">
    <source>Please provide more information</source>
    <context-group purpose="location">
      <context context-type="sourcefile">src/app/features/game/components/game-boosting.ts</context>
      <context context-type="linenumber">150</context>
    </context-group>
    <note priority="1" from="description">Form validation error</note>
  </trans-unit>

  <trans-unit id="5273018339487538226" datatype="html">
    <source> Please provide more information </source>
    <context-group purpose="location">
      <context context-type="sourcefile">src/app/features/users/components/user/user.html</context>
      <context context-type="linenumber">19,21</context>
    </context-group>
  </trans-unit>

它们都具有相同的 source 标签内容,因此其中一个有空格包裹它。

为了避免这个错误,我必须将 .html 代码放在一行中,但这会与我的美化发生冲突。

目前:

    <eld-error-message i18n *ngIf="formSubmitAttempt && !userReportFormGroup.get('message')?.valid"
    >
      Please provide more information
    </eld-error-message>

使其工作(但无效的解决方案):

    <eld-error-message i18n *ngIf="formSubmitAttempt && !userReportFormGroup.get('message')?.valid">Please provide more information</eld-error-message>

有没有办法将这些文本视为重复并忽略空格?

angular localization internationalization angular-i18n
1个回答
0
投票

我认为不可能将这些线条视为相同。您可以编写脚本在生成翻译后删除空格,但我认为这不值得付出努力。作为妥协,我建议配置您的格式化程序以通过以下方式格式化此类行:

<eld-error-message i18n *ngIf="formSubmitAttempt && !userReportFormGroup.get('message')?.valid"
      >Please provide more information</eld-error-message
>

您也可以尝试:

<eld-error-message i18n *ngIf="formSubmitAttempt && !userReportFormGroup.get('message')?.valid"
    >{{
      'Please provide more information'
    }}</eld-error-message>

但我不确定这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.