martinroob / ngx-i18nsupport

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

Auto Translate with $localize delete variables. #166

Open Ricardo96r opened 4 years ago

Ricardo96r commented 4 years ago

I am trying to Auto Translate the $localize of my application. The problem is that when translating $localize the variables are erased.

Example:

$localize'El campo tiene muy pocos caracteres. Mínimo ${o.requiredLength} caracteres. (${o.actualLength})'

Default XLF (messages.xlf Original defaultLanguage: es)

<trans-unit id="854483955309547493" datatype="html">
    <source>El campo tiene muy pocos caracteres. Mínimo <x id="PH"/> caracteres. (<x id="PH_1"/>)</source>
    <target>El campo tiene muy pocos caracteres. Mínimo <x id="PH"/> caracteres. (<x id="PH_1"/>)</target>
</trans-unit>

Then i run xliffmerge --profile apps/web/xliffmerge.json and generate: (messages.en.xlf):

<trans-unit id="854483955309547493" datatype="html">
    <source>El campo tiene muy pocos caracteres. Mínimo <x id="PH"/> caracteres. (<x id="PH_1"/>)</source>
    <target state="translated">The field has very few characters. Minimum characters. ()</target>
</trans-unit>

As you can see, the element <x id = "PH" /> and <x id="PH_1"/> is removed.

It is necessary that it is not deleted, since my application has 17 languages and it is very laborious to add it manually

Any idea how to make the element <x id = "PH" /> not be deleted?


My xliffmerge.json:

  "xliffmergeOptions": {
    "srcDir": "apps/web/src/locale",
    "genDir": "apps/web/src/locale",
    "i18nFile": "messages.xlf",
    "i18nBaseFile": "messages",
    "i18nFormat": "xlf",
    "encoding": "UTF-8",
    "defaultLanguage": "es",
    "languages": ["es", "en", "zh", "da", "de", "nl", "fr", "ht", "hi", "it", "ja", "ko", "pt", "ru", "sv", "tr", "uk"],
    "removeUnusedIds": false,
    "supportNgxTranslate": false,
    "useSourceAsTarget": true,
    "beautifyOutput": false,
    "preserveOrder": true,
    "allowIdChange": false,
    "autotranslate": true,
    "apikeyfile": "/users/me/.secrets/googleTranslateApiKey.txt",
    "verbose": false,
    "quiet": false
  }
}
Blucbo commented 4 years ago

Hi, do you solve the issue?

lfsmoura commented 4 years ago

Is there a workaround for this issue? is it possible to mark trans units as "not removable"?

Blucbo commented 4 years ago

Is there a workaround for this issue? is it possible to mark trans units as "not removable"?

You can add into template text with same ids

daniel-sc commented 3 years ago

$localize is only recognized if you use ivy to extract: ng xi18n --ivy