Utilizing ngx-translate to switch the language of my application has proven to be quite challenging. My application consists of different languages specifically for testing purposes and is divided into separate modules with lazy loading functionality.
As a result, I am dealing with two variables related to language settings. The first variable pertains to the CV of the individual where the text changes based on the selected language. The second variable applies to all other components and modules within the application.
The issue arises when using translate.use(cvLanguage) as it ends up translating the entire application. This same problem extends to main components that exist outside of this module.
I attempted to use isolation in the Translate Module, but unfortunately, it did not yield the desired results.
Below is a snippet of my code:
app.module.ts
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: httpTranslateLoader,
deps: [HttpClient],
},
}),
export function httpTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http);
}
And here is the user.module:
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: httpTranslateLoader
},
isolate: true
}),
export function httpTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http);
}
Despite attempting to segregate the translations into modules and isolating them accordingly, the issue persists.