Add `langChanged$` observable
See original GitHub issueIs your feature request related to a problem? Please describe.
TranslocoService provides an observable that emits when the language is about to change. But there is no observable that emits when the language has changed.
Current behavior
When using langChanges$
to trigger rerendering a pipe the pipe rerenders but the language has not been loaded yet and therefor the pipe rerenders in the same language as before. This would be useful for https://github.com/ngneat/transloco/issues/443
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Translation API | Transloco Angular i18n - GitHub Pages
Returns an observable that when subscribed loads and emits the given language translation object, if no language is passed the active language will...
Read more >How to Nest Multiple Observables/Subscriptions
And the subscription as I have it: this.langChanged .subscribe(newLang => { console.log( ...
Read more >ngneat-transloco/lobby - Gitter
langChanges $ | async) }} , i.e. I pass the langChanges observable as an async parameter to my pipe, ... I installed it...
Read more >[Solved]-How to Nest Multiple Observables/Subscriptions-rx.js
langChanged .subscribe(newLang => { console.log(`language changed ... I also added a second Subject cancelLangChange which is meant to cancel the forkJoin ...
Read more >Change the language of your Angular components in ...
npx @angular/cli add @ngneat/transloco --langs en,bg,es ... Translation } from "@ngneat/transloco" import { Observable } from "rxjs" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Added PR https://github.com/ngneat/transloco/pull/534
I face with the very same problem in our project as well. I’ve already tried with
events$
which can help when the first lang change happens, but it is not fired after that.I need to translate computed keys programmatically in the controller. So this is working fine now:
But is this really a good API to use? Why should I call
buildHRParams()
twice? Why should I subscribe in a subscription for the (kind of the) same event?langChanges$
is fired before loading the other language fileevents$
fired only when real loading happened and not the cache has been used. We could say that it’s “bug” should be fixed and fire atranslationLoadSuccess
event even when loaded from the cache but I’d still say that why should I do 2 subscription for the 1 event I am interested of.It’s easy to see that there is a valid need to have a
langChanged$
event which is fired always after having the new translations available.I don’t know if there is any reason to fire the
langChanges$
event before loading the translations but if there is none then even that could be changed to be fired after the loading.