0 votes
in Angular by
What happens if the custom id is not unique?

1 Answer

0 votes
by

You need to define custom ids as unique. If you use the same id for two different text messages then only the first one is extracted. But its translation is used in place of both original text messages.

For example, let's define same custom id myCustomId for two messages,

<h2 i18n="@@myCustomId">Good morning</h3>
<!-- ... -->
<h2 i18n="@@myCustomId">Good night</p>

and the translation unit generated for first text in for German language as

<trans-unit id="myId" datatype="html">
  <source>Good morning</source>
  <target state="new">Guten Morgen</target>
</trans-unit>

Since custom id is the same, both of the elements in the translation contain the same text as below

<h2>Guten Morgen</h2>
<h2>Guten Morgen</h2>
...