angular - Internationalize and Localize option using Ionic2/Angular2 -


i developing ionic2/angular2 app android mobile.

i want provide option user choose language option in login page.

is there way app level internationalization using ionic2/angular2?

i have not seen many examples device level internationalization.

you need these:

translate_providers, translateservice, translatepipe, translateloader, translatestaticloader 

you can find them here, example:

import {http_providers} '@angular/http'; import {component, injectable} '@angular/core'; import {translate_providers, translateservice, translatepipe, translateloader, translatestaticloader} 'ng2-translate/ng2-translate'; import {bootstrap} '@angular/platform-browser-dynamic';  bootstrap(appcomponent, [     http_providers,     // not required, recommended have 1 unique instance of service     translate_providers ]);  @component({     selector: 'app',     template: `         <div>{{ 'hello' | translate:{value: param} }}</div>     `,     pipes: [translatepipe] }) export class appcomponent {     param: string = "world";      constructor(translate: translateservice) {         var userlang = navigator.language.split('-')[0]; // use navigator lang if available         userlang = /(fr|en)/gi.test(userlang) ? userlang : 'en';           // language used fallback when translation isn't found in current language         translate.setdefaultlang('en');           // lang use, if lang isn't available, use current loader them         translate.use(userlang);     } } 

source: https://github.com/ocombe/ng2-translate


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -