-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Feature request] Make the pipe update the translation when the language changes #35
Comments
@Finesse Hello and sorry, somehow i missed your post.
So impure pipe would cause perfomance freezes (mostlty because of zonejs). And it wouldn't solve probles with already resolved LOCALE_ID and angular pipes dependent on it LOCALE_ID (it can be updated only rebootstraping angular or refreshing page). Hack with the creating copy of value of translation key could help us:
But our key (for example: 'common:hello') is string and it is not a reference type (but a value type), you can't change reference pointer as you could do with an object. And changing language doesn't change a key, it is still the same. |
@Romanchuk Thank you for the explanation (though I haven’t comprehended it because I don’t know Angular guts). It’s sad that Angular restrains us with such ridiculous limitations.
Maybe you can return this pipe as an extra pipe? For example <div>
{{ 'tranlation_key' | i18nextEager }}
</div> |
Hi @Finesse please take a look at this simple implementation of i18next, shows how to change the language, plurals, etc... at least for me is always easier look at a sample code |
@Finesse It is possible, i'll think about it in first half of january |
@scastaldi As I can see, the component reloads the page when the language changes. This is not what I want to achieve. @Romanchuk It would be great. Thank you! |
@Finesse Hi, i just released version 7.2.0-beta with a new i18nextEager pipe. It is impure pipe so i highly recommend to use it only in combine with OnPush change detection strategy, or else (default change detection) each pipe will retrigger more than one time. You can use it without reloading page. |
@Romanchuk Thank you, I’ll try it today
Could you please give me a link where I can read about this strategy (especially how to use it with a pipe) |
@Finesse
With zone.js and Default change detection enabled it will cause huge perfomance issues |
@Romanchuk It works as expected, thank you! The first link was helpful. The issue is resolved for me. |
Ok, i will release stable version and update docs to cover i18nextEager pipe usage |
Docs updated |
I use components with HTML like this:
The key gets translated on a component mount but it isn't retranslated when I change the language by calling:
A retranslated text is shown only when the component is updated by another reason. I intuitively expect the
i18next
pipe to update the translation when the language changes like theasync
pipe does.I'm not an expert in Angular, but as far as I know there is a way to force a component update from pipe.
Maybe there is another way to retranslate the components on language change? I really don't want to reload the whole page like in your demo, I consider it as user unfriendly.
BTW,
this.i18NextService.events.languageChanged.subscribe
works well in my components.The text was updated successfully, but these errors were encountered: