angular.io icon indicating copy to clipboard operation
angular.io copied to clipboard

i18n docs need better documentation for AoT compilation

Open jetfontanilla opened this issue 9 years ago • 3 comments

on https://angular.io/docs/ts/latest/cookbook/i18n.html

Next, issue an ngc compile command for each supported language (including English). The result is a separate version of the application for each language.

the website only states this part: ./node_modules/.bin/ngc --i18nFile=./locale/messages.fr.xlf --locale=fr --i18nFormat=xlf but it's actually incomplete.

if you do these commands sequentially: ./node_modules/.bin/ngc --i18nFile=./locale/messages.fr.xlf --locale=fr --i18nFormat=xlf ./node_modules/.bin/ngc --i18nFile=./locale/messages.es.xlf --locale=es --i18nFormat=xlf the earlier compiled fr ngfactory gets overwritten with the es ngfactory

so the earlier statement doesn't really apply since it seems that you can only have 1 i18n compiled application at a time, and doesn't produce a separate application

you can also replicate this one on my POC repo: https://github.com/jetlogs/Angular2-AOT-Localization

once you've set up the project:

  • npm run compile:aot:ja
  • check aot/app/quiz-app/quiz-app.component.ngfactory.ts
  • verify that the compiled templates are in Japanese
  • npm run compile:aot:ko
  • check aot/app/quiz-app/quiz-app.component.ngfactory.ts
  • verify that the compiled templates are in Korean, Japanese version gets overridden

dependencies used:

"dependencies": {
    "@angular/common": "^2.1.0",
    "@angular/compiler": "^2.1.0",
    "@angular/compiler-cli": "^2.1.0",
    "@angular/core": "^2.1.0",
    "@angular/forms": "^2.1.0",
    "@angular/http": "^2.1.0",
    "@angular/platform-browser": "^2.1.0",
    "@angular/platform-browser-dynamic": "^2.1.0",
    "@angular/platform-server": "^2.1.0",
    "@angular/router": "^3.1.0",
    "@angular/upgrade": "^2.1.0",

jetfontanilla avatar Oct 18 '16 13:10 jetfontanilla

Also, where does the compiled app go? What can you do with it? How do you run it, especially with a particular translated locale, e.g. with angular-cli?

wcainboundary avatar Nov 08 '16 22:11 wcainboundary

How do you run it, especially with a particular translated locale

Exactly: where can I decide which language to serve? Directly in the index.html, loading a bundle or another? How?

ghidoz avatar Dec 13 '16 10:12 ghidoz

Please update docs

Aiuspaktyn avatar Feb 08 '17 17:02 Aiuspaktyn