daniel-sc / ng-extract-i18n-merge

Extract and merge i18n xliff translation files for angular projects.
MIT License
170 stars 18 forks source link

Merge without target-item #20

Closed vorlif closed 2 years ago

vorlif commented 2 years ago

Hi,

first of all, thank you for your library. It makes my life much easier. :+1:

I was expecting that if I set "newTranslationTargetsBlank": true, there would be no translation and when building the app the original language would be used. So, it would be clear to any user that there is still a translation missing here.

Unfortunately, however, a <target/> is inserted into the xlf file, which ensures that the string is no longer displayed at all and content is suddenly missing from the app.

Is it possible to do the merge in a way that the new strings are taken over and no <target/> is inserted?

Example:

Instead of this

...
    <unit id="1234565678984936453432">
      <segment state="initial">
        <source>Original</source>
        <target/>
      </segment>
    </unit>
...

I would find this better

...
    <unit id="1234565678984936453432">
      <segment state="initial">
        <source>Original</source>
      </segment>
    </unit>
...
daniel-sc commented 2 years ago

Hi @Vorlif

not sure if I get your intend here. To leave texts in the original/source language until they are translated, I'd be recommended to set newTranslationTargetsBlank: false - that way the target is populated with the source:

...
    <unit id="1234565678984936453432">
      <segment state="initial">
        <source>Original</source>
        <target>Original</target>
      </segment>
    </unit>
...

Would this solve your problem?

vorlif commented 2 years ago

Hi @daniel-sc

Thanks for your quick reply. newTranslationTargetsBlank: false would be a workaround for me, but not a nice solution. I would like to leave the missing translations blank and display the original text as a fallback.

Through <target/>, it is assumed that the translation is an empty string and this empty string is also displayed in the frontend. So nothing is displayed. But without <target/> it is assumed that no translation is available and the original language (which should be translated) is displayed as fallback. This would also be more in line with the real intention.

I know that newTranslationTargetsBlank: false has the same effect in the frontend. But it also puts the original language as translation everywhere and I would like to avoid that.

But I can understand if you say that's not your library's job. I just thought I would propose it once.

daniel-sc commented 2 years ago

I understand - maybe it makes sense to add a third option (besides true/false) such as "noTargetElement". Not sure when I find time for this, but I'll definitely give it a try - but if you'd like to create a PR I'd be happy to help!