Improve .get() to update whenever language is being changed with .use()
See original GitHub issueI’m submitting a … (check one with “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
[x] feature request
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):
this.translate.get(['pages.user.title', 'menus.user.profile']).subscribe((res) => {
this.breadcrumb.addFriendlyNameForRoute('/users', res['pages.user.title']);
this.breadcrumb.addFriendlyNameForRoute('/users/edit', res['menus.user.profile']);
});
If I would use .onLangChange
code would look something like this:
this.translate.get(['pages.user.title', 'menus.user.profile']).subscribe((res) => {
this.breadcrumb.addFriendlyNameForRoute('/users', res['pages.user.title']);
this.breadcrumb.addFriendlyNameForRoute('/users/edit', res['menus.user.profile']);
});
this.translate.onLangChange.subscribe(() => {
this.translate.get(['pages.user.title', 'menus.user.profile']).subscribe((res) => {
this.breadcrumb.addFriendlyNameForRoute('/users', res['pages.user.title']);
this.breadcrumb.addFriendlyNameForRoute('/users/edit', res['menus.user.profile']);
});
});
Please tell us about your environment:
-
ng2-translate version: 4.0.1
-
Angular version: 2.2.1
-
Browser: [all]
-
Language: [all]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:12 (1 by maintainers)
Top Results From Across the Web
How to Manage Programming Language Upgrades and EOL
Learn how to reduce the costs of upgrading open source languages, as well as best practices when a programming language becomes EOL.
Read more >How to refresh activity after changing language (Locale ...
Register an OnSharedPreferenceChangeListener , in its onShredPreferenceChanged() , invoke restartActivity() if language preference was changed.
Read more >Do programming languages 'update' (change) themselves ...
Yes, they change over time. There is no official process where this happens, except some languages have been adopted by standards committees, ...
Read more >How to change your Automatic Updates settings by using ...
How to change your Automatic Updates settings by using Windows Security Center. Microsoft Windows XP Service Pack 2 Microsoft Windows XP Home Edition...
Read more >Update the IDE and SDK Tools - Android Developers
Update your IDE and change channels · Open the Preferences window by clicking File > Settings (on Mac, Android Studio > Preferences). ·...
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 FreeTop 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
Top GitHub Comments
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
get
would silently lead to memory leaks I think adding a new function would be less destructive.Any ideas for the function name? I’ll send the PR in the meantime but will change the name to whatever’s suggested here.
Not yet, but should be in the next major