gilsdav / ngx-translate-router

Translate routes using ngx-translate
132 stars 43 forks source link

services won't get called again when changing language #116

Open pixelatorz opened 3 years ago

pixelatorz commented 3 years ago

If I am correct this repo is a fork from the Greentube/localize-router.

We changed the greentube one to this one, everything seems to be working fine, however there seems to be one issue.

When changing the language with the Greentube code the page seems to do a hard refresh and services get called again with the correct language.

When using ngx-translate-router this does not happen, causing the site to translate everything thats loaded through the translation files, but not refreshing the content loaded through services.

Its possible to build a workaround by listening to the language changes and then calling the services again but in a large application thats quite some overhead.

any Idea on how to solve this?

gilsdav commented 3 years ago

Hello @pixelatorz,

That's correct and this is a wanted feature (do not recreate complete component when it's exactly the same one).

The good way is to use .stream() and not .get() from ngx-translate into your RXJS logics.

Otherwise it's possible to go back to default "reuse component strategy" using this code:

{
      provide: RouteReuseStrategy,
      useClass: DefaultRouteReuseStrategy
 }