Language Config Library in Angular 2/4
This library use @ngx-translate dependencies and its own service to manage the translations in the language selects that can be by configuration and in case it is not configured by default the language of the browser.
Instructions to install and configure
From github
$ npm install https://github.com/mugan86/ng-2-4-language-config.git#0.2.1
From NPM (Stable version)
$ npm install ng-2-4-language-config --save
and then from your Angular AppModule:
;;;// Import our library;
then from your Angular AppComponent to use LanguageConfigService to load translate files:
;
If you select want language:
;
Finally, we must add the translation files to the correct directory, which will be in src/assets/i18n/language-code.json. For example for Spanish, we must add the file src/assets/i18n/es.json.
How to use it in the template?
Now having all this correctly configured, we visualize it in the layout making use of Pipe 'translate'
{{ label | translate}}
License
MIT © Anartz Mugika