-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 10 not supporting xliffmerge #180
Comments
I'm running this command in Angular 11: |
"ng extract-i18n projectName --ivy --format xlf --outputPath outputFolder && ng run projectName:xliffmerge" In my case the first part of the command ng extract-i18n projectName --ivy --format xlf --outputPath outputFolder works fine and it generates message.xlf file but the second part of the command which is "ng run projectName:xliffmerge" An unhandled exception occurred: Could not find the implementation for builder @ngx-i18nsupport/tooling:xliffmerge I am stucked at merging the message.xlf file with other locale files. |
@coder123er Add LanguageUse the i18n project option in your app's build configuration file (
For example, the following excerpt of an
With this change you will be able to start the Norwegian version of the app and make sure the translations are working: ng serve --configuration=nb --open XliffmergeWe use a tool called Xliffmerge to create the localized translation files. Add the new language to the configurations in "xliffmerge": {
"options": {
"xliffmergeOptions": {
"defaultLanguage": "en-US",
"languages": ["nb"]
}
}
} Apply specific build options for just one localeTo apply specific build options to only one locale, you can create a custom locale-specific configuration in "build": {
"configurations": {
"nb": {
"localize": ["nb"]
}
}
},
"serve": {
"configurations": {
"nb": {
"browserTarget": "portal:build:nb"
}
}
} You can then pass this configuration to the ng serve or ng build commands with Add a new line to the language specific start commands (
Language FilesTo create translation files for each language we copy the source language file. For example, to create a Norwegian translation file make a copy of the Doing this for all files every time there is a new translation is a bit tedious so we can use tooling for this. With the help of xliffmerge we can run a script that extracts the translations and merges them into the language files with the command: npm run translations We send all the translations to the |
@melcor76 could you please help me with this. |
@parvdhunna Looking at your configurations it looks you are doing it the old way. The error message is also complaining about your build configuration. The Angular docs have excellent explanations how you should do it now: https://angular.io/guide/i18n#define-locales-in-the-build-configuration Basically when quickly looking at it you should change this:
To this:
You also need to add this part:
|
@melcor76 I have done changes in my angular.json file as mentioned by you and provided in the article. This is my command which I execute "extract-i18n": "ng xi18n angular --ivy --format xlf --outputPath assets/locale && ng run angular:xliffmerge" And the error i get on executing it If you can check there are any other changes to be done in angular.json { |
@coder123er Can't see anything wrong. Reading the error message I would try reinstalling xliffmerge to the latest version. |
Check this tool https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-angular9-app-with-xlf-files I have the same problem as you when updating to Angular 11, it seems that the xliffmerge tool is no longer supported and there are no updates in the Github repository. Babel's translation program merges the xlf files that you enter, establishing the primary language you can translate in as many languages as you need and the string extraction is always performed on the primary language. |
I have been working on an Angular i18n article and while doing it I did some experimentation to get Xliffmerge working on a new project. This is the important part of what I write in the article: The documentation for Xliffmerge is targeting older versions of Angular but after some experimentation I found that it’s enough to install the
Then we can add new languages to the configurations in angular.json under
After adding new translations we can extract them and migrate them to our translation files by running this script:
We get a couple of warnings running the script which tells us its working!
|
Earlier we were using Angular 7 for our project and the following command worked for us for Localization
"extract-i18n": "ng xi18n projectName --i18n-format xlf --output-path src/locale --i18n-locale en && ng run projectName:xliffmerge"
The above command generated xlf file and also merged it with other localized files.
But now We have upgraded to Angular version 10 and on executing above command the terminal gives us error.
What is the new approach in Angular 10 to generate and merge localized files.
The text was updated successfully, but these errors were encountered: