Lazy loaded module specific JSON translation file not loading
See original GitHub issueI’m submitting a
[x] feature request => load child module specific translation JSON file
Current behavior
In my lazy loaded child module account.module.ts
I’m importing TranslateModule
with forChild()
@NgModule({
imports: [
CommonModule,
HttpModule,
FormsModule,
AccountRoutingModule,
TranslateModule.forChild({
loader: { provide: TranslateLoader, useClass: AccountTranslationLoader, deps: [Http] },
})
],
})
export class AccountModule { }
I have custom translate loader AccountTranslationLoader
written as
export class AccountTranslationLoader implements TranslateLoader {
constructor(private http: Http) {}
getTranslation(lang: string): Observable<any> {
return this.http.get(`./assets/i18n/account/${lang}.json`)
}
}
Currently the expected json file request is never made and translation in child module views not working.
Expected/desired behavior
It is expected to load the child module json translation file and append it to the previously loaded translation file loaded from AppModule
using TranslateModule.forRoot()
Please tell us about your environment:
-
ngx-translate version: ^7.0.0
-
Angular version: ^4.1.3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:17 (2 by maintainers)
Top Results From Across the Web
ngx-translate is not working for lazy loaded module
I want to implement ngx-translate in angular 5 project lazy loaded module wise its working for only parent module but not works in...
Read more >Lazy translations loading from Angular | ISPsystem
The translations within the projects are stored in json files. ... We will indicate in the angular module what chunk of translation we...
Read more >How to split your i18n file per lazy loaded module with ngx ...
To be able to load a json file along with a lazy loaded module you have to use the property isolate as the...
Read more >Scope Configuration | Transloco Angular i18n - GitHub Pages
... a lazy load module, or a component's providers. Let's say we have a todos page and we want to create separate translation...
Read more >Lazy-loading feature modules - Angular
Click on the Orders or Customers button. If you see a chunk appear, everything is wired up properly and the feature module is...
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
The GET request is never made because there are no subscribers on the Observable for fetching the child JSON. I assume translate.use() is used in the root to set language, which auto-subscribes and completes for root only Source: translate.use. It does not automatically fetch the JSON for the child.
Make a test by subscribing to onLangChange() manually in the child module and change the language in code. It should fetch the JSON.
@panagulis72 it does not work for me actually even in a child module which is lazy loaded it does not work and never loads language.