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:
tonic889
2022-02-06 00:44:52 -05:00
parent 6770f0bb78
commit b5218f34a2
2 changed files with 6 additions and 3 deletions
+6 -3
View File
@@ -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
View File