-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
I18nPipe does not update in response to AlainI18NService.change events #2529
Comments
In fact, NG-ALAIN did initially rely on ngx-translate as part of its internationalization. However, over time, it was discovered that if internationalization data can be confirmed at the Angular startup, the implementation method of ngx-translate is not as developer-friendly. Therefore, NG-ALAIN provides a simplified approach, which assumes that internationalization data is always ready to be used. Of course, aside from relying on For refreshing internationalization, I believe using NG-ALAIN does not strictly enforce using the default implementation and can fully utilize DI rules to override this default behavior. |
Do you mean override the Pipe itself? |
The contract seems to be that A very simple caching strategy (like the one linked to above in |
Angular's dependency injection can help you override NG-ALAIN's default behavior, including |
Reproduction link
The reference project on stackblitz would not finish installing npm dependencies, so I was not able to create a minimal reproduction. codesandbox was consistently hanging and crashing my browser (chrome and Edge on two different machines).
Steps to reproduce
When using ChangeDetectionStrategy.OnPush, components which use the I18nPipe are not updated when the AlainI18NService.change observable emits a new value.
What is expected?
Components should update when AlainI18NService.change emits.
What is actually happening?
Since the pipe is declared as "pure", AlainI18NService change events are ignored.
The implementation from ngx-translate can be used as a reference.
A proper implementation would do the following:
pure
attribute to false in the decoratorAlainI18NService.fanyi
AlainI18NService.change
observable and recompute the cache translation appropriately.AlainI18NService.change
in anngOnDestroy
callbackThe text was updated successfully, but these errors were encountered: