Angular internationalization - XLIFF with HTML tags

Viewed 879

I was wondering if it's possible to translate portions of the page where there are HTML tags within the text.

Example:

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

My translation file looks like this:

<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>

When I try to run my project with ng serve I get the following error:

ERROR in Unknown placeholder START_LINK

I checked online (https://github.com/angular/angular/issues/25242) and if I understood correctly, it seems like HTML is not meant to be embed to the translation files.

Do you guys have any workaround for that?

Thanks you!

1 Answers

Yes it is. you have to split the each text node with any other tag around the a tag.

Related