TranslateService not working in root after upgrade to Beta.10


#1

Hi there,

After upgrading my project to beta.10 the translate service stopped working in the root html (app.html). The sidenav is there. The translate service is working ok in all the other pages.

Does someone else encountered this? How can I fix it?

I am using TranslateService and TranslatePipe form ng2-translate

Thanks in advance


#2

It’s still working for me


#3

In your root file (app.html)? In all my other files its working fine but in the app.html it stopped working. All I have in this file is the sidemenu code, so all the navigation is not being translated…

Could you show me you app.ts file (imports, etc) to see if I am missing something?

Thanks in advance


#4

I think I detected the problem. I am setting the language after doing a Promise so the translate.use(lang) inside the “then” statement is not updating the view.
I do not know why the translate.use(lang) is not updating the view…


#5

The only fix I found to make it work is to call 2 times the “use” method like this:

this.translate.use(lang);
this.translate.use(lang);

By doing this, the first call fails to update the view when the language is changed but then the second call updates the view fine…


#6

I wonder if it’s working for me because of the default language being set before the current language?

this.translate.setDefaultLang('en');
this.translate.use(this.settings.language);

Though it works fine if the language is saved as not-english and the app restarted. I don’t really know, this framework is fairly new for me, but it’s working.


#7

Than you beck24. I tried putting the set default language first and it still does not work. I will leave the two consecutive calls to the use method, it’s the only way I could make it work.