Bug(scope): Scoping doesn't work in routes loaded with loadChildren #783
Replies: 4 comments
-
The issue with your reproduction is that you are not triggering a load for the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@CitrusyAlmond There are no stupid questions 🙂 I'm trying to understand your use-case though. Do you only need translations inside the components? Transloco's loading mechanism was intended to be internal and not managed by the consumers. If you further explain your use-case I can maybe assist more. Also, take a look at the preload langs plugin, it might be what you are looking for or you can take inspiration from the implementation code. |
Beta Was this translation helpful? Give feedback.
-
There's some translations that are used in templates, however I also use them in a series of third party components like Kendo Notification which accepts a message to display. I gave the preload langs plugin a look, however from what I understood, I'd have to add all the scopes that I might want to use on components during the app, which might be too many. So far, I came up with a really ugly implementation that allows me to check when the scopes are loaded by looping on the scopes array received from the TRANSLOCO_SCOPE value, and using firstValueFrom to await them. While this "works", I know how ineffective it is, and would appreciate some guidance on a method that I might have missed, or a suggestion if a way is not already implemented. Sorry for taking so long, and thank you for your time. |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Which Transloco package(s) are the source of the bug?
Transloco
Is this a regression?
Yes
Current behavior
The function provideTranslocoScope only applies the scopes assigned to the parent element. It doesn't seem to work either in the lazy loaded route file nor the child component's Type Decorator.
This is a screenshot of the main routes file.
This is a screenshot of the child routes file.
When using this._transloco.getTranslation(), it only shows the translations from the language.json file as well as those from the scope assigned in the parent element.
Expected behavior
The function provideTranslocoScope to not also apply the scopes assigned to it in the main routes file, but also those imported using the loadChildren function.
Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.
https://codesandbox.io/s/tmt5zn
Transloco Config
No response
Please provide the environment you discovered this bug in
Browser
No response
Additional context
No response
I would like to make a pull request for this bug
No
Beta Was this translation helpful? Give feedback.
All reactions