【问题标题】:Angular internationalization - XLIFF with HTML tagsAngular 国际化 - 带有 HTML 标签的 XLIFF
【发布时间】:2018-12-21 02:23:15
【问题描述】:

我想知道是否可以翻译文本中包含 HTML 标记的页面部分。

例子:

<p i18n="@@genericError">
    Please Try again or <a href="https://help.companyx.com">get in touch</a> with us for help.
</p>

我的翻译文件如下所示:

<trans-unit id="genericError" datatype="html">
    <source>
        Please Try again or <x id="START_LINK" ctype="x-a" equiv-text="&lt;a&gt;" />get in touch<x id="CLOSE_LINK" ctype="x-a" equiv-text="&lt;/a&gt;" /> with us for help.
    </source>
    <target>
        Por favor tente novamente ou <x id="START_LINK" ctype="x-a" equiv-text="&lt;a&gt;" />entre em contato<x id="CLOSE_LINK" ctype="x-a" equiv-text="&lt;/a&gt;" /> conosco.
    </target>
</trans-unit>

当我尝试使用 ng serve 运行我的项目时,出现以下错误:

未知占位符 START_LINK 中的错误

我在网上查了一下 (https://github.com/angular/angular/issues/25242),如果我理解正确的话,似乎 HTML 并不打算嵌入到翻译文件中。

你们有什么解决方法吗?

谢谢!

【问题讨论】:

    标签: angular angular6 xliff


    【解决方案1】:

    是的。您必须将每个文本节点与 a 标签周围的任何其他标签分开。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-10
      • 2023-04-11
      • 2018-04-29
      相关资源
      最近更新 更多