Angular-cli: support multiple i18n under the same build pipeline

Created on 27 Nov 2019  路  5Comments  路  Source: angular/angular-cli

馃殌 Feature request

Command (mark with an x)


- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [x] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

A clear and concise description of the problem or missing capability...

When supporting multiple languages in angular, we have to build multiple times, it would cost quite a long time with middle size applications.

Describe the solution you'd like

If you have a solution in mind, please describe it.

Could we build multiple langs at the same time with the latest cli now? since the translation part was moved to the end of the build pipeline, and there is a new configuration in angular.json, according to the integration test here

ng build --configuration production,fr

https://github.com/angular/angular/tree/master/integration/cli-hello-world-ivy-i18n

Describe alternatives you've considered

support some commands like ng build --configuration production,fr,de

devkibuild-angular docs

Most helpful comment

That is correct. This is one of the new features of 9.0. Thank you @elvisbegovic.

Also of note is once you setup the i18n configuration for a project you can run ng build --prod --localize to generate outputs for all the defined locales without the need to add the configuration or individual configurations. However, you still can setup your application using the individual configurations if preferred.
Documentation for this is currently in review and will be available for the final 9.0 release.

All 5 comments

hmm if i understand... this is already possible afaik, by adding new configuration like :
"myTranslateConfig": {"localize": ["fr","de","en","it"]}
And run ng build --prod --c myTranslateConfig

  • myTranslateConfig should translate all your locales from files you specify except sourceLocal which simply remove $localize from default build.

fyi: I consider you are on rc3 and already run ng update @angular/cli --migrateOnly --from=8 to get new i18n object config in angular.json under your project:

"i18n": {
  "sourceLocale": "fr",
    "locales": {
      "de": "./locale/de.xtb", 
      "en": "./locale/en.xtb", 
      "it": "./locale/it.xtb"
  }
},

If you try rc3 right now, there is some bugs regarding new i18n you should manually fix, I recommend wait next release to get

@clydin can correct me if im wrong

That is correct. This is one of the new features of 9.0. Thank you @elvisbegovic.

Also of note is once you setup the i18n configuration for a project you can run ng build --prod --localize to generate outputs for all the defined locales without the need to add the configuration or individual configurations. However, you still can setup your application using the individual configurations if preferred.
Documentation for this is currently in review and will be available for the final 9.0 release.

Additionally, the --configuration production,fr,de option syntax is to support configuration composition. This essentially merges the options of each of the specified configurations. The later specified configurations take priority over the earlier.

Several documentation updates have now landed and the update guide can be found here: https://v9.angular.io/guide/i18n

Suggestions and comments for improvement are welcome.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings