Same translations in different files

230 Views Asked by At

I have two .html files that use the same translation i18n="@@MY_TRANSLATION". Is it okay to use the same i18n in two different files, or even the text is the same I do need to use different key? For instance, i18n="@@MY_TRANSLATION_2", but in this case the same translation appears in .xlf file twice.

1

There are 1 best solutions below

0
Lars On

If you want to translate exactly the same text in both files, but it should appear only once in the translation file, then you can give both texts the same ID. This is totally fine. If the content is different it will display a warning, when exporting the translation file.

If you use two separate IDs, like in your example, this will result in two separate translations in the XLIFF. If you have different content that needs to be translated you need to use different IDs, this is also stated in the documentation.

Be sure to define custom IDs that are unique. If you use the same ID for two different text elements, the extraction tool extracts only the first one, and Angular uses the translation in place of both original text elements.

See also the Manage marked text with custom IDs in the Angular documentation. This page probably clarifies most questions.