Skip to content

Commit b5f82d8

Browse files
committed
fix(i18n): use APP_BASE_HREF in deps
1 parent 904ad5e commit b5f82d8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Client/app/app.module.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, Inject } from '@angular/core';
22
import { RouterModule } from '@angular/router';
33
import { CommonModule, APP_BASE_HREF } from '@angular/common';
44
import { HttpModule, Http } from '@angular/http';
@@ -21,11 +21,9 @@ import { Ng2BootstrapComponent } from './containers/ng2-bootstrap-demo/ng2bootst
2121
import { LinkService } from './shared/link.service';
2222
import { ConnectionResolver } from './shared/route.resolver';
2323

24-
export function createTranslateLoader(http: Http) {
25-
26-
// BUG: URLs requested via Http on the server must be absolute
27-
// TODO: Should not hardcode localhost://5000, should use APP_BASE_HREF!!
28-
return new TranslateHttpLoader(http, 'http://localhost:5000/assets/i18n/', '.json');
24+
export function createTranslateLoader(http: Http, APP_BASE_HREF) {
25+
// i18n files are in `wwwroot/assets/`
26+
return new TranslateHttpLoader(http, `${APP_BASE_HREF}/assets/i18n/`, '.json');
2927
}
3028

3129
@NgModule({
@@ -49,7 +47,7 @@ export function createTranslateLoader(http: Http) {
4947
loader: {
5048
provide: TranslateLoader,
5149
useFactory: (createTranslateLoader),
52-
deps: [Http]
50+
deps: [Http, [new Inject(), APP_BASE_HREF]]
5351
}
5452
}),
5553

@@ -67,7 +65,7 @@ export function createTranslateLoader(http: Http) {
6765
// We're using "data" in our Routes to pass in our <title> <meta> <link> tag information
6866
// Note: This is only happening for ROOT level Routes, you'd have to add some additional logic if you wanted this for Child level routing
6967
// When you change Routes it will automatically append these to your document for you on the Server-side
70-
// - check out app.component.ts to see how it's doing this
68+
// - check out app.component.ts to see how it's doing this
7169
data: {
7270
title: 'Homepage',
7371
meta: [{ name: 'description', content: 'This is an example Description Meta tag!' }],

0 commit comments

Comments
 (0)