I want to build a web-application with angular2 and bundle this with webpack. What is the best way for providing multiple languages:
i18n-plugin: https://github.com/
If you are using angular-cli
you can follow these steps:
Be aware that your app must be AOT compatibe, so you should be able to build it with
--aot
switch:ng build --aot
Extract messages with ng xi18n
command with location for translation file given:
ng xi18n --output-path src/i18n
You will get src/i18n/messages.xlf
file. Copy this file and translate messages to languages you need:
src/i18n/messages.en.xlf
src/i18n/messages.pl.xlf
Serve/build your app with ng serve / ng build
command (change locale accordingly):
ng serve --i18n-file=src/i18n/messages.en.xlf --locale=en --i18n-format=xlf --aot