From b5218f34a2eaf1e09d76d95636ccf1ce88c30e37 Mon Sep 17 00:00:00 2001 From: tonic889 Date: Sun, 6 Feb 2022 00:44:52 -0500 Subject: [PATCH] fix(core.module.ts): change translation service to consider base url Fixes issue with translation files not being loaded when base url is not null (e.g localhost:4200/web-app) Fixes: #1366 --- src/app/core/core.module.ts | 9 ++++++--- src/karma.conf.js | 0 2 files changed, 6 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/karma.conf.js diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 192837186..381301e55 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -38,6 +38,9 @@ import { SidenavComponent } from './shell/sidenav/sidenav.component'; import { ToolbarComponent } from './shell/toolbar/toolbar.component'; import { BreadcrumbComponent } from './shell/breadcrumb/breadcrumb.component'; import { ContentComponent } from './shell/content/content.component'; +import { InjectionToken } from '@angular/core'; +import { APP_BASE_HREF, LocationStrategy } from '@angular/common'; + /** * Core Module @@ -51,10 +54,10 @@ import { ContentComponent } from './shell/content/content.component'; TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useFactory: (http: HttpClient) => { - return new TranslateHttpLoader(http, `${ window.location.protocol }//${ window.location.host }/assets/translations/`, '.json'); + useFactory: (http: HttpClient, locationStrategy: LocationStrategy) => { + return new TranslateHttpLoader(http, `${ window.location.protocol }//${ window.location.host }${locationStrategy.getBaseHref()}/assets/translations/`, '.json'); }, - deps: [HttpClient] + deps: [HttpClient, LocationStrategy] } }), RouterModule diff --git a/src/karma.conf.js b/src/karma.conf.js old mode 100644 new mode 100755