Core: Observerable from TranslateService called only once

Created on 22 Mar 2017  路  5Comments  路  Source: ngx-translate/core

I'm submitting a bug

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Function as parameter inside subscribe (translateService.get().subscribe()) called only once. In case of using translateService.get().subscribe() after change language function in subscribe never calls again

Expected/desired behavior
Observerable from translateService.get(key) should be endless to be able to call subscribe after any changes which can affect return value for key.

Reproduction of the problem

  1. open plunker
  2. click Toogle lang button

AR1=ER1: text after "Pipe" changed
AR2: text after "Service" not changed
ER2: text after "Service" changed
(AR - actual result \ current behavoir; ER - expected result \expected behavoir)

What is the motivation / use case for changing the behavior?
Use case to make work translateService.get().subscribe() same as pipe or directive.

Please tell us about your environment:

  • ngx-translate version: 6.x.x

  • Angular version: 2.x.x

  • Browser: [all]

Most helpful comment

Use .stream() instead of .get()

All 5 comments

Hello, I also ran into this problem:
see the plunker based on the plunker of @ocombe with the current ngx-translate package (@stswoon: Your plunker uses the older ng2-translate package, that's why I created another one).

Does anyone can validate, that this is a bug? Or is it a missing feature? Or do we use it the wrong way?

Ngx-translate team please respond at least bug it or not.

By the way I've tried to make fix, e.g. make subcription from get be called on every lang change (see link), it works but some test are failed now.

It's not a bug, but it's a missing feature yes

any update about this missing feature?

Use .stream() instead of .get()

Was this page helpful?
0 / 5 - 0 ratings