-
-
Notifications
You must be signed in to change notification settings - Fork 576
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
Angular translation forchild not loading #1266
Comments
I've the same issue, I think it's because the same TranslateService is shared in the 2 modules, and it uses the configuration given in 'TranslateModule.forRoot'. |
For lazy-loaded modules with different translation loaders (loading
It's like I can't blend the two. I got pretty close though maybe you could have a look and play within |
I have an angular application that uses ngx-translation. For this, I made a Shared module that loads a translation file containing different keys (general errors...) :
`@NgModule({
imports: [
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: TranslateFactory,
deps: [HttpClient]
}
}),
],
exports: [TranslateModule],
})
export class TranslatorModule {
constructor(translate: TranslateService){
translate.addLangs(['fr']);
translate.setDefaultLang('fr');
}
}
export function TranslateFactory(http: HttpClient) {
return new TranslationService(http, 'assets/i18n');
}`
In my AppModule, I load this module and I also load another translation file via forRoot :
`@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
SharedModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: TranslateFactory,
deps: [HttpClient]
}
}),
],
bootstrap: [AppComponent]
})
export class AppModule{
}
export function TranslateFactory(http: HttpClient) {
return new TranslationService(http, 'assets/i18n/myApp');
}`
My problem is that only translateService.forRoot works. Translations from translateService.forChild are not loaded
Then I just use my shareModule in my loaded modules in lazy loading mode
The text was updated successfully, but these errors were encountered: