ngx translate Angular 5

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



ngx translate Angular 5



When I change the language in settings.ts (page) and check currentLanguage in the same page, it changes the language correctly and show it.



But when I do the same thing in app.component.ts, CurrentLanguage does not change even if i change it 10 times.



Here is the code. Button for language change is in settings.html



settings.ts


import TranslateService from '@ngx-translate/core';

constructor(private translate: TranslateService)
//code...

changeLang(lang)
this.translate.use("en");
console.log("Switched to ", this.translate.currentLang);
this.translate.use("ru");
console.log("Switched to ", this.translate.currentLang);



app.component.ts


import TranslateService from '@ngx-translate/core';


constructor(private translate: TranslateService)
//code...


this.translate.use("ru");
console.log("it is ", this.translate.currentLang);
this.translate.use("en");
console.log("it is ", this.translate.currentLang);
this.translate.use("ru");
console.log("it is ", this.translate.currentLang);



Output for settings.ts


Switched to en
Switched to ru



Output for app.component.ts


it is to ru
it is to ru
it is to ru





Do you only have a single AppModule or do you have multiple?
– Daniel
Aug 10 at 11:56





@Daniel Single.
– Profom Stat
Aug 10 at 13:32









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS