martinroob / ngx-i18nsupport

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

$localize usage in component is reset on every extraction #176

Open spock123 opened 3 years ago

spock123 commented 3 years ago

UPDATE UPDATE

I noticed that if the translation state is set to "translated", it works as designed. If the state = final it will be overwritten on each extraction.

Hi, I'm using $localize to generate translations inside component classes.

Example:

public order = $localize:@@order.order-step-label:;

However, after running extraction, while the field is found and inserted in the messages file, both source and target for the translations are empty:

<source/><target state="final"/>

Further, if we translate it and update the translation file, on the next extraction run, the translations are reset to the initial empty state again.

Any ways we can prevent this? It makes it impossible to use the tool as all our translations are removed each time we run the script.

Configuration:

{
  "xliffmergeOptions": {
    "srcDir": "src/locale",
    "genDir": "src/locale",
    "i18nFile": "messages.xlf",
    "i18nBaseFile": "messages",
    "i18nFormat": "xlf",
    "encoding": "UTF-8",
    "defaultLanguage": "en",
    "languages": ["en", "da"],
    "removeUnusedIds": true,
    "supportNgxTranslate": false,
    "ngxTranslateExtractionPattern": "@@",
    "useSourceAsTarget": true,
    "targetPraefix": "",
    "targetSuffix": "",
    "beautifyOutput": false,
    "preserveOrder": true,
    "allowIdChange": false,
    "autotranslate": false,
    "apikey": "",
    "apikeyfile": "",
    "verbose": false,
    "quiet": false
  }
}
julkue commented 3 years ago

The problem is, it's only compatible with Angular v8 currently, where $localize didn't even exist. See https://github.com/martinroob/ngx-i18nsupport/issues/167

ahmadalfy commented 3 years ago

@julmot it's compatible with 10 as well

julkue commented 3 years ago

@ahmadalfy Yes, the base functionality that was already present with v8 kept working up and including to v10 (not v11). But it's not officially compatible, thus a feature like $localize that wasn't there in v8 isn't officially supported, see: https://github.com/martinroob/ngx-i18nsupport/blob/master/package.json#L30

ahmadalfy commented 3 years ago

@julmot you're right, I found that I am not using it. I ended up removing it from my project and used xliffmerge from the same author.