Is possible to get translate.currentLang from any page?

Hi, i use a ng2-translate plugin for translate my app.

in index page i set my default language but if I get the currentLang in second page the value is undefined.

in my index.ts page the code is:

import { TranslateService } from 'ng2-translate/ng2-translate';

constructor(public navCtrl: NavController, public navParams: NavParams, translate: TranslateService) {
    translate.setDefaultLang('en');
}

my secondpage.ts :

import { TranslateService } from 'ng2-translate/ng2-translate';

constructor(public navCtrl: NavController, public navParams: NavParams, translate: TranslateService) {
  console.log(translate.currentLang)
}

any solution?

You have to set this value in your app.component.ts

I also recommend to update from ng2-translate to ngx-translate: https://ionicframework.com/docs//resources/ng2-translate/

What is the latest version? ng2 o ngx?

they renamed ng2 to ngx.
I updated the docs to ngx-translate

Ok thank you!
I set the default value and the used value in app.components.ts

now works :slight_smile: