In my Ionic/Angular project, I am utilizing ngx-translate along with ngx-translate/http-loader for language translation. Within my app.module.ts imports, I have the following code:
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpBackend]
}
})
Additionally, within the same file, there is the loader function defined as:
export function createTranslateLoader(handler: HttpBackend) {
const http = new HttpClient(handler);
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
This setup allows me to use the translate pipe in HTML components like so: {{ 'TEXT' | translate }}
, and also to perform translations in component TypeScript files using:
var text = this.translateService.instant("TEXT");
However, when attempting to use translateService.instant
within a service created with "ng generate s"
, it returns the string "TEXT
" itself instead of the translated text. What could be causing this issue?