martinroob / ngx-i18nsupport

Some tooling to be used for Angular i18n workflows
MIT License
283 stars 69 forks source link

xliffmerge overwrites source if different #178

Open bubblegumsoldier opened 3 years ago

bubblegumsoldier commented 3 years ago

Hello,

it seems like the xliffmerge tool doesn't solely rely on the id but overwrites the source and target if the source in the target-file is differing from the one that is supposed to be merged. Sounds oddly specific and confusing? Yes, but here is an example:

Let's say we have a target file called messages.en.xlf with a tag like this:

<trans-unit id="lang-en" datatype="html">
        <source>EN - English</source>
        <target>EN - English</target>
        <note priority="1" from="description">Translated Name for English language</note>
</trans-unit>

and I have an origin file that I extracted from my code called messages.xlf with the following tag:

<trans-unit id="lang-en">
  <source>English</source>
  <note priority="1" from="description">Translated Name for English language</note>
</trans-unit>

When I use xliff merge with default language en to merge the second into the first it will merge it but the output (new messages.en.xlf-file) looks like this:

<trans-unit id="lang-en" datatype="html">
        <source>English</source>
        <target>English</target>
        <note priority="1" from="description">Translated Name for English language</note>
</trans-unit>

So why is it overwriting the source and the target? For other languages other than "en" (e.g. "ru") this does not happen and the source and target of the messages.ru.xlf-file is used.

This is my xliffmergeOptions.json-file that I am using:

{
  "xliffmergeOptions": {
    "srcDir": "./apps/web-client-dt2020/src/locale",
    "genDir": "./apps/web-client-dt2020/src/locale",
    "i18nFile": "messages.xlf",
    "i18nBaseFile": "messages",
    "i18nFormat": "xlf",
    "encoding": "UTF-8",
    "defaultLanguage": "..",
    "languages": [
      "en",
      "de",
      "ru",
      "fr",
      "es",
      "zh"
    ],
    "removeUnusedIds": true,
    "supportNgxTranslate": false,
    "useSourceAsTarget": true,
    "targetPraefix": "",
    "targetSuffix": "",
    "beautifyOutput": true,
    "allowIdChange": false,
    "autotranslate": false,
    "verbose": false,
    "quiet": false
  }
}

I use the following command to execute it:

xliffmerge --profile xliffmergeOptions.json

Is this behaviour supposed to happen? Why isn't the already translated file seen as truth and only the id used as a reference point?