Merge pull request #1372 from tonic889/issue-1366

fix(core.module.ts): change translation service to consider base url
This commit is contained in:
Avik Ganguly
2022-03-28 20:17:04 +05:30
committed by GitHub
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 { ToolbarComponent } from './shell/toolbar/toolbar.component';
import { BreadcrumbComponent } from './shell/breadcrumb/breadcrumb.component'; import { BreadcrumbComponent } from './shell/breadcrumb/breadcrumb.component';
import { ContentComponent } from './shell/content/content.component'; import { ContentComponent } from './shell/content/content.component';
import { InjectionToken } from '@angular/core';
import { APP_BASE_HREF, LocationStrategy } from '@angular/common';
/** /**
* Core Module * Core Module
@@ -51,10 +54,10 @@ import { ContentComponent } from './shell/content/content.component';
TranslateModule.forRoot({ TranslateModule.forRoot({
loader: { loader: {
provide: TranslateLoader, provide: TranslateLoader,
useFactory: (http: HttpClient) => { useFactory: (http: HttpClient, locationStrategy: LocationStrategy) => {
return new TranslateHttpLoader(http, `${ window.location.protocol }//${ window.location.host }/assets/translations/`, '.json'); return new TranslateHttpLoader(http, `${ window.location.protocol }//${ window.location.host }${locationStrategy.getBaseHref()}/assets/translations/`, '.json');
}, },
deps: [HttpClient] deps: [HttpClient, LocationStrategy]
} }
}), }),
RouterModule RouterModule
Regular → Executable
View File