import { Inject, NgModule, PLATFORM_ID, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; import { LanguageService } from '@hdca/fe-angular-shared'; import { StoreModule } from '@ngrx/store'; import { globalNotificationReducers } from './reducers'; import { TransferState } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { HttpClient } from '@angular/common/http'; import { TranslatesBrowserLoaderService } from '../translation/translation-browser/translation-browser-loader.service'; import { TranslatesServerLoaderService } from '../translation/translation-server/translation-server-loader.service'; import { GlobalNotificationContainer } from './containers/global-notification/global-notification.container'; import { GlobalNotificationItemContainer } from './containers/global-notification-item/global-notification-item.container'; export function translateStaticLoader(http: HttpClient, transferState: TransferState): TranslatesBrowserLoaderService | TranslatesServerLoaderService { return new TranslatesBrowserLoaderService('/node-assets/i18n/store-selectors/', '.json', transferState, http); } @NgModule({ imports: [ CommonModule, StoreModule.forFeature('globalNotification', globalNotificationReducers), TranslateModule.forChild({ loader: { provide: TranslateLoader, useFactory: translateStaticLoader, deps: [HttpClient, TransferState] } }) ], declarations: [ GlobalNotificationContainer, GlobalNotificationItemContainer ], exports: [ GlobalNotificationContainer ] }) export class HDCAGlobalNotificationModule { constructor(private languageService: LanguageService, @Inject(PLATFORM_ID) platformId: any) { const lang = this.languageService.getLanguage(); this.languageService.setLanguage(lang); } static forRoot(): ModuleWithProviders { return { ngModule: HDCAGlobalNotificationModule }; } }