使用i18n在Angular中进行翻译

时间:2019-08-10 12:35:20

标签: angular internationalization

我是i18n的新手,我需要使用单个id转换整个div,但似乎找不到任何可以帮助我将html标记转换为xliff的指南。

我已经看过本指南https://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2-cd02.html,但是我还不能转换任何东西,那是我的代码

<div i18n="@@abl1">
 <h2>hello</h2>
 <h3>how are you</h3>
</div>

这就是我尝试过的:

<trans-unit id="abl1" datatype="html">
 <source>
  <x id="START_TAG_H2" ctype="x-h2" equiv-text="&lt;h2&gt;"/>
   Hello
   <x id="CLOSE_TAG_H2" ctype="x-h2" equiv-text="&lt;/h2&gt;"/>
   <x id="START_TAG_H3" ctype="x-h3" equiv-text="&lt;h3&gt;"/>
    How are you?
   <x id="CLOSE_TAG_H3" ctype="x-h3" equiv-text="&lt;/h3&gt;"/>
  </source>
  <target>
   <x id="START_TAG_H2" ctype="x-h2" equiv-text="&lt;h2&gt;"/>
    Salut
   <x id="CLOSE_TAG_H2" ctype="x-h2" equiv-text="&lt;/h2&gt;"/>
   <x id="START_TAG_H3" ctype="x-h3" equiv-text="&lt;h3&gt;"/>
    Comment vas tu?
   <x id="CLOSE_TAG_H3" ctype="x-h3" equiv-text="&lt;/h3&gt;"/>
  </target>
  <context-group purpose="location">
  <context context-type="sourcefile">src/app/propos/propos.component.html 
  </context>
 </context-group>
</trans-unit>

当我使用跨度和强度尝试此方法时,它工作得很好,但是当我将其与h2和h3一起使用时,出现以下错误:

ERROR in Unknown placeholder "START_TAG_H2" (" [ERROR ->]
<x id="START_TAG_H2" ctype="x-h2" equiv-text="&lt;h2&gt;"/>
Salut
<x id="CLOSE_"): i18n@1:10
Unknown placeholder "CLOSE_TAG_H2" (" 
<x id="START_TAG_H2" ctype="x-h2" equiv-text="&lt;h2&gt;"/>
Salut
[ERROR ->]<x id="CLOSE_TAG_H2" ctype="x-h2" equiv-text="&lt;/h2&gt;"/>
<x id="START_TAG_H3" ctype="x-"): i18n@3:10
Unknown placeholder "START_TAG_H3" ("
Salut<x id="CLOSE_TAG_H2" ctype="x-h2" equiv-text="&lt;/h2&gt;"/>
[ERROR ->]<x id="START_TAG_H3" ctype="x-h3" equiv-text="&lt;h3&gt;"/>
Comment vas tu?<x "): i18n@4:10
Unknown placeholder "CLOSE_TAG_H3" ("  
<x id="START_TAG_H3" ctype="x-h3" equiv-text="&lt;h3&gt;"/>
Comment vas tu?[ERROR ->]
<x id="CLOSE_TAG_H3" ctype="x-h3" equiv-text="&lt;/h3&gt;"/>"): i18n@6:10

我该如何进行?

0 个答案:

没有答案