Updates to i18n translation files in Angular
An alternative/new solution (to the unmaintained ngx-i18nsupport) is https://github.com/daniel-sc/ng-extract-i18n-merge
After installing via
ng add ng-extract-i18n-merge
translations will be extracted and merged with the command:
ng extract-i18n
Edited answer
You can use the xliffmerge tool. It can merge translation files after you've added new translations in your html
Here is a tutorial for angular
Basically after running your normal extract command you call xliffmerge and pass the language(s) for which you want to generate translation files
ng xi18n --outputPath src/locale/ --locale en && xliffmerge --profile xliffmerge.json en fr
You can specify a json config for the tool
{
"xliffmergeOptions": {
"srcDir": "src/locale",
"genDir": "src/locale"
}
}
Original answer
Try setting custom ids to your translations
https://angular.io/guide/i18n#set-a-custom-id-for-persistence-and-maintenance
<h1 i18n="@@introductionHeader">Hello i18n!</h1>
Nex time you run the extract command, it'll just add the new blocks but won't touch the existing ones
Btw I think going with the native option is a good choice, since the maintainer of the main alternative (ngx-translate) is actually working with the angular team on the native approach