-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve .get() to update whenever language is being changed with .use() #330
Comments
Or you could do: this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.breadcrumb.addFriendlyNameForRoute('/users', event.translations['pages']['user']['title']);
this.breadcrumb.addFriendlyNameForRoute('/users/edit', event.translations['menus']['user.profile']);
}); A LangChangeEvent is an object with the properties lang: string & translations: any (an object containing your translations). But I understand what you mean, you'd like an observable that would be like get but permanent, I'll see what I can do |
I tried that yesterday(night), but it didn't work on first load, for example, my app loads - I set the language, then I decide to navigate to users page(where that |
Ahhh good point. Should I change |
I'm not sure, wouldn't it break something if you change the |
Does this mean the user would have to unsubscribe manually to prevent memory leaks? |
@SamVerschueren I assume that would be the same thing as with |
@ocombe Any progress on this? |
Not yet, but should be in the next major |
This would drastically simplify a lot of our components and I'll even send a PR for it to - hopefully - get it into a release. Since changing the current Any ideas for the function name? I'll send the PR in the meantime but will change the name to whatever's suggested here. |
…ranslations that updates on lang change Fixes #330
:O Great. |
I'm merging a few other PRs and I'll release a new version |
Looking forward to see changelog :) |
I'm submitting a ... (check one with "x")
Current behavior
Whenever I change language, parts in my code where I use .get doesn't change. I am aware of
onLangChange
, but that wouldn't make sense for me to use it.Expected/desired behavior
It should call again on subscribtion with new languages translations. I assume that observable has completed and that is why it is not calling anymore(haven't looked at source).
Reproduction of the problem
Example code of what I have now (using with ng2-breadcrumbs):
If I would use
.onLangChange
code would look something like this:Please tell us about your environment:
ng2-translate version: 4.0.1
Angular version: 2.2.1
Browser: [all]
Language: [all]
The text was updated successfully, but these errors were encountered: