Core: Translate.get : When changing language, subscribers not notified .

Created on 25 Sep 2017  路  4Comments  路  Source: ngx-translate/core

I'm submitting a bug report

[x] bug report =>  when changing language, subscribers not notified 

Current behavior
when subscribe to translate.get() the subscription end automatically . check the next screen shot .

Expected/desired behavior
i need to be still subscribing so when language change the code will rerun a again

Reproduction of the problem

this.translate.get('videoUrl').subscribe(
     (videoUrl:any)=>{
        console.log('i am a subscriber , changing video url ', videoUrl);
        // do this stuff when language change 
      },
      (e)=>{ console.error('i am a subscriber, this is error, ');},
      ()=>{ console.log('i am a subscriber , i am ended ');}
);

image

What is the expected behavior?
i need to be still subscribing so when language change the code will rerun a again

What is the motivation / use case for changing the behavior?
it will be awesome, my current situation, i change the video based on language and create some code configuration

Please tell us about your environment:

@angular/cli: 1.4.3
node: 7.7.3
os: win32 x64
  • ngx-translate version: 7.0.0

  • Angular version: 4.4.3

  • Browser: [Chrome Version 61 (Official Build) (64-bit) ]

Most helpful comment

Use .stream() instead of .get()

https://github.com/ngx-translate/core#methods

All 4 comments

678

Same thing. In my case, I'm translating some strings using service instead of a pipe, so I need to automatically change this string if language was changed.

Use .stream() instead of .get()

https://github.com/ngx-translate/core#methods

Thanks a lot @dennisroters It works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guysan picture guysan  路  4Comments

briancullinan picture briancullinan  路  3Comments

crebuh picture crebuh  路  3Comments

apreg picture apreg  路  3Comments

egornoveo picture egornoveo  路  4Comments