Angular CLI with i18n localization (XMB file)

Is there any complete example for i18n default localization using the latest angular cli? I did the following:

  • ng new <project>

  • cd <project>


    ng build -prod

    OK
  • update app.component.html with this i18n attribute in h1 tag:
    <h1 i18n="site header|An introduction header@@header"> Welcome to {{title}}! </h1>

  • extract i18n with command:
    ng xi18n --locale en --output-path localize -xmb --out-file msg.en.xmb

    OK
  • create a copy msg.en.xmb

    asmsg.sk.xmb

  • change the 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>

  • ??? What now?

I tried:

A) what I expected ng serve --locale sk --i18n-format xmb --i18n-file localize/msg.sk.xmb


RESULT: No error, after switching to local text does not change: Welcome to the application!

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 happened.

C) etc., for example, generate an assembly for the production of (any assembly with --aot

or assembly for the -prod

ends 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 with Angular-cli (but no exact steps on how to get it to work with an XMB file).

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

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

+3


source to share





All Articles