I've created my own private angular library with multiple components to make my life easier. I made this library by following this tutorial. Everything worked out great I even added it to another project to test it out.
Now comes the part where I have to support multiple languages because I live in Belgium π. I've used the ngx-translate package in the past without any problem so i thought this would be easy.
I added an assets/i18n folder with the translation json's in my project.
I've found out that angular cli doesn't include the assets on build so you have to add them manually or with gulp to the dist folder before making the package. After doing that I noticed that the labels were not being translated unless I included the translation to the json files of the Main application.
Each component in my library has its own module so I thought I just needed to add the translation module in those modules. So I did the following.
export function httpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
imports: [
CommonModule,
FormsModule,
DirectivesModule,
ButtonModule,
IconModule,
PillModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: (httpLoaderFactory),
deps: [HttpClient]
},
isolate: true
})
],
declarations: [
FilterComponent
],
exports: [
FilterComponent
]
})
This made things even worse, not only were the labels still not being translated, my main applications didn't even use its own translations. The main application didn't have a problem with its translations before those changes in the library modules...
So yeah you guessed it, I am stuck... I can't seem to find the right solution.