You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Translations provided at a component level are not detected. Language change is also not propagated to "nested" translate services.
Expected behavior
The nested component to have access to both the translation at the root, and the translation loaded by the child module in its providers.
I was also expecting the language change at the root to be propagated upwards.
How do you think that we should fix this?
The TranslateService seems to not have enouth code to handle the case where additional loaders are provided after initialization.
Minimal reproduction of the problem with instructions
Default branch of the project
Everything else ic coming from the repo config
Browser:
Chrome desktop
For Tooling issues:
Node version: 22.11
Platform: Mac + Linux
The text was updated successfully, but these errors were encountered:
piotaixr
changed the title
How to use extends (and/or) isolate to provide translations at the component/lazt-loaded module level?
How to use extends (and/or) isolate to provide translations at the component/lazy-loaded module level?
Nov 7, 2024
Isolate means that the instance you create is completely independent from the other ones. I've inspected the code so far... isolate should work as it is. The implementation is not perfect and I've refactored it 7b72914
However the extend feature seems indeed broken. I am not sure if this happened during changes for v16 or was broken before. It seems that there were no tests for this use-case - thanks for providing one.
I would say that a language change should propagate to all instances of the translate service that are shared and not isolated.
I am not yet sure about the behaviour of the extend feature. setTranslations() merges the translations in the shared main store. use() is somehow designed to also merge them into the main store if extend is set - but does not uses a flat merge instead of mergeDeep()... this is one thing that has to be fixed for sure.
I just wonder, if merging is a good idea. The disadvantage is that components using the same key would overwrite the translations for all.
Another option instead would be to create some kind of augmentation. In a component, would check its "local" store first for translations and fall back to the root store if missing. This would allow using the same ID in multiple components.
The bigger issue for me is that I have no idea who is relying on the current behaviour and what side effects changes might make...
Current behavior
Translations provided at a component level are not detected. Language change is also not propagated to "nested" translate services.
Expected behavior
The nested component to have access to both the translation at the root, and the translation loaded by the child module in its providers.
I was also expecting the language change at the root to be propagated upwards.
How do you think that we should fix this?
The TranslateService seems to not have enouth code to handle the case where additional loaders are provided after initialization.
Minimal reproduction of the problem with instructions
I added a failing test case in my fork here: https://github.com/piotaixr/ngx-translate-core/tree/bug/extends
Environment
Default branch of the project
Everything else ic coming from the repo config
Browser:
Chrome desktop
For Tooling issues:
The text was updated successfully, but these errors were encountered: