I want to implement ngx-translate in angular 5 project lazy loaded module wise its working for only parent module but not works in my child module so please suggest better solution.
I write my code for app module .
and i am using @ngx-translate/core and @ngx-translate/http-loader
app.module.ts
TranslateModule.forRoot({
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
LayoutModule,
HttpClientModule,
BrowserAnimationsModule,
HttpModule, ReactiveFormsModule,
RouterModule.forRoot(
appRoutes,
{ enableTracing: false }
),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient]
}
})
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/app/', '.json');
}
child.module.ts
@NgModule({
imports: [
RouterModule,
CommonModule,
BrowserModule,
BrowserAnimationsModule,
GridModule,
DropDownsModule,
FormsModule,
ExcelModule,
ControlMessagesModule, ReactiveFormsModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: (AdminTranslateLoader),
deps: [HttpClient]
},
isolate: true
})
],
export function AdminTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/admin/', '.json');
}
'./assets/i18n/app/'
for both modules and see if it works. I am using same file across different modules and it is working fine to me – Yousef khan