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
This commit is contained in:
@@ -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
|
||||
|
||||
Regular → Executable
Reference in New Issue
Block a user