InterviewHubPRO
Section Overview
Q182

Question 182 of 283

Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

64%
Angular & Signals (283 Qs)•Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

What happens if the custom id is not unique?

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,

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

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

html
<h2>Guten Morgen</h2>
<h2>Guten Morgen</h2>