Lazy loaded module is not adding the new custom translateLoader
See original GitHub issueI’m submitting a … (check one with “x”)
[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
[ ] feature request
Current behavior When a lazy loaded module is being loaded it triggers the factory for create the new TranslateHttpLoader however it is not adding the translations in the file
Expected/desired behavior Load the translations of the lazy loaded module
Reproduction of the problem I can’t provide a plnkr because but this is the code that i’m using
export function translateFactory(http: Http) {
return new TranslateHttpLoader(http, '/metro-apps/maintenances/i18n/', '.json');
}
[...]
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: translateFactory,
deps: [Http]
}
})
Please tell us about your environment: Kubuntu 16.04
-
ngx-translate version: core=6.0.0 loader: 0.0.3
-
Angular version: 2.4.7
-
Browser: all
Issue Analytics
- State:
- Created 7 years ago
- Reactions:19
- Comments:26 (8 by maintainers)
Top Results From Across the Web
ngx-translate is not working for lazy loaded module
Configured the project as: Added TranslateModule.forRoot() in app.module.ts like. export function httpLoaderFactory ...
Read more >Creating lazy-loaded modules - IBM
Lazy -loaded modules typically correspond to features. It is recommended that the features in these modules are added to a folder called features....
Read more >@ngx-translate/core - npm
1. Import the TranslateModule : Finally, you can use ngx-translate in your Angular project. You have to import TranslateModule.forRoot() in the ...
Read more >Working With Lazy Loading Modules and Preload Routing ...
When we build an Angular application with multiple modules in a large app, ... and add preload and custom strategies for loading modules....
Read more >ngx-translate Documentation - CodeAndWeb
Since lazy loaded modules use a different injector from the rest of your ... You have to create the translate loader inside a...
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
Just bumped into this as well.
I wanted my app module to fetch translations from “/assets/i18n/{lang}.json” and my lazy loaded modules to fetch from “/assets/i18n/{feature}/{lang}.json” but was unable to get this to work.
The custom loader configured by forChild(…) was ignored.
I never managed to do it. So I created my own service to add translations to the root translateModule. I have a resolver for the routes accessing the lazyloaded module calling loadTranslationModule() before resolving.