I made further checks in my application.
The language picker changes selection language.
The service is singleton, if I change pages, and request translation using 
the next code, the translation is well reported.
However, the application does NOT refresh. how to trig a refresh ?? 
I displayed some translations in the language picker, itself, it does not 
refresh ....altough language is changed.
Is it because it uses translation pipe in the messages that are not 
refreshed ... ?

 
this.translate.get('my text').subscribe(
  value => {
  console.log("translated :");
  console.log(value);
  }




Le vendredi 18 août 2017 11:31:17 UTC+2, becto...@gmail.com a écrit :
>
> if i am using the translate service in angular4+
>
> Can i share data between components just importing this 
> translateService. Pretty much I want that service to remember which 
> language I set it to. Or is this something i need to create my own service 
> for to share the language i set my app to in order to get it in between 
> components. 
> import { TranslateService } from '@ngx-translate/core';
>
>
>  constructor(public translate: TranslateService, public data: DataService) 
> {
>    this.data = data;
>    translate.addLangs(['en', 'fr']);
>    const browserLang: string = translate.getBrowserLang();
>    translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
>
> }
>
>
>
>
>
> how could I then in another component figure out which 
> languauge translate.use() was already set to? Or can the translateService 
> not persist data between components and i would have to use the DataService 
> that i wrote myself to store it?
>
> Thanks 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to