For extracting translations I use i18n in combination with xliffmerge.
I have added the extract-i18n
command in the package.json
like so:
"extract-i18n": "ng extract-i18n project --i18n-format xlf --output-path src/locale --i18n-locale en-US && ng run project:xliffmerge"
The xliffmergeOptions
in angular.json
are:
"xliffmerge": {
"builder": "@ngx-i18nsupport/tooling:xliffmerge",
"options": {
"xliffmergeOptions": {
"format": "xlf",
"srcDir": "src/locale",
"genDir": "src/locale",
"defaultLanguage": "en-US",
"languages": [
"en-US",
"nl-NL"
]
}
}
}
Whenever I run the extract-i18n
command the messages.xlf file still gets exported to the root folder instead of src/locale.
I have no idea why it isn't exported to the src/locale folder.
Update
After upgrading from Angular 11 to Angular 12 this problem still persists.
I made the mistake of running ng extract-i18n
while configuring it in a script in package.json. Instead I should have used npm run extract-i18n
.
This solves only a part of the problem though, since --i18n-format
and --18n-locale
are no longer supported (or so it seems).
The correct command should be:
"extract-i18n": "ng extract-i18n [projectname] --format xlf --output-path src/locale && ng run [projectname]:xliffmerge"
Due to Angular deprecating the keyword "id" in the schema on favor of "$id" I'm not sure how long xliffmerge will continue to work though, since development on ngx-i18nsupport has stopped a few years ago.