Angular CLI with i18n localization (XMB file)

Viewed 842

Is there any complete example for default i18n localization using latest angular cli? I proceeded as follows:

  1. ng new <project>
  2. cd <project>
    ng build -prod OK
  3. update app.component.html with this i18n attribute in h1 tag:
    <h1 i18n="site header|An introduction header@@header"> Welcome to {{title}}! </h1>
  4. extract i18n with command:
    ng xi18n --locale en --output-path localize -xmb --out-file msg.en.xmb OK
  5. create copy of msg.en.xmb as msg.sk.xmb
  6. modify text in msg.sk.xmb to "Ahoj"
    <messagebundle> <msg id="header" desc="An introduction header" meaning="site header"><source>app\app.component.ts:3,5</source> Ahoj <ph name="INTERPOLATION"><ex>INTERPOLATION</ex></ph>! </msg> </messagebundle>

  7. ??? what to do now?

I tried:

A) what I expected ng serve --locale sk --i18n-format xmb --i18n-file localize/msg.sk.xmb
RESULT: No error, after go to localhost text is not changed: Welcome to app!

B) full path: ng serve --locale sk --i18n-format xmb --i18n-file c:\Angular\project\localize\msg.sk.xmb
RESULT as in A) no error, nothing happend.

C) other, like generate build for production (any build with --aot or build for -prod finish with an error: Can't resolve './$$_gendir/app/app.module.ngfactory'...)

Also checked this: https://github.com/angular/angular-cli/wiki/stories-internationalization and this answer Localization in Angular2 using Angular-cli (but there is no exact steps how to get it work with XMB file).

How to finish translation in xmb files and use it for serve / build translated app? Can you recommend me the commands from step 7?

My versions (latest for 2017-07-24): @angular/cli: 1.2.4, node: 8.2.1, os: win32 x64

0 Answers
Related