import { NgModule } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { TranslateModule , TranslateService , TranslateLoader , MissingTranslationHandler } from '@ngx-translate/core' ; import { translatePartialLoader , missingTranslationHandler } from 'app/config/translation.config' ; import { SessionStorageService } from 'ngx-webstorage' ; @ NgModule ( { imports : [ TranslateModule . forRoot ( { loader : { provide : TranslateLoader , useFactory : translatePartialLoader , deps : [ HttpClient ] , } , missingTranslationHandler : { provide : MissingTranslationHandler , useFactory : missingTranslationHandler , } , } ) , ] , } ) export class TranslationModule { constructor ( private translateService , sessionStorageService ) { translateService . setDefaultLang ( 'en' ) ; const langKey = sessionStorageService . retrieve ( 'locale' ) ?? 'en' ; translateService . use ( langKey ) ; } }