Currently, our team is developing a website using Angular 6 and Visual Studio Code. The site will eventually support multiple languages, but for now, we are focusing on Swedish and English, with English set as the default language. To extract strings from HTML files, we utilize the xi18n
command, while the ngx-extractor
command from i18n-polyfill
helps us extract strings from TypeScript files.
My dilemma lies in wanting to integrate translation seamlessly into the coding process, rather than treating it as an afterthought at the project's end. I aim to update both HTML and TypeScript strings simultaneously within the translation files. However, the current command I use removes TypeScript strings when running it after extracting HTML strings using xliff
.
The commands specified in package.json are:
"scripts": {
"i18n-extract": "ng xi18n --output-path=locale --out-file messages.xlf --i18n-locale en && xliffmerge",
"ngx-extract": "ngx-extractor -i ./src/**/*.ts -f xlf -o ./src/locale/messages.xlf --i18n-locale en && xliffmerge"
},
"xliffmergeOptions": {
"srcDir": "src/locale",
"genDir": "src/locale",
"i18nFile": "messages.xlf",
(Additional configuration options were present here.)
(For the complete text with unchanged content, please refer to the original passage provided above.)