Skip to content

Conversation

@hakonamatata
Copy link
Contributor

@hakonamatata hakonamatata commented Apr 5, 2017

Added i18n support

Translated part of the side to Norwegian to show an example of it working.

One problem:

export function createTranslateLoader(http: Http) {

    // BUG: URLs requested via Http on the server must be absolute
    // TODO: Should not hardcode localhost, should use APP_BASE_HREF!!
    return new TranslateHttpLoader(http, 'http://localhost:5000/assets/i18n/', '.json');
}

^ I hardcoded the url of the translation files to localhost at port 5000, this should be changed to the current APP_BASE_HREF.

But it work fine to run locally at port 5000.

Closes #111

@MarkPieszak
Copy link
Member

ngx-translate very nice! 👍
Does it work fine when it's using APP_BASE_HREF ?

@hakonamatata
Copy link
Contributor Author

I assume it will work using APP_BASE_HREF, but could not figure out exactly how to inject that into the createTranslateLoader function 😕

@MarkPieszak MarkPieszak merged commit 904ad5e into TrilonIO:master Apr 5, 2017
@MarkPieszak
Copy link
Member

MarkPieszak commented Apr 5, 2017

Merged & fixed it! @hakonamatata
Oh by the way the SignalR demo was acting up? Just commented out the link in the navigation, but not sure what went wrong?

This is fantastic Jan thank you again for helping! Going to try and fix up the webpack & Azure stuff today.

        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: (createTranslateLoader),
                deps: [Http, [new Inject(), APP_BASE_HREF]] // <--
            }
        }),

export function createTranslateLoader(http: Http, APP_BASE_HREF) {
    // i18n files are in `wwwroot/assets/`
    return new TranslateHttpLoader(http, `${APP_BASE_HREF}/assets/i18n/`, '.json');
}

@hakonamatata
Copy link
Contributor Author

Glad I can help 😊

I'll take a second look at the signalR implementation too

@hakonamatata
Copy link
Contributor Author

Tried your solution, but I get an error here:

deps: [Http, [new Inject(), APP_BASE_HREF]]

Severity	Code	Description	Project	File	Line	Suppression State
Error	TS2346	Supplied parameters do not match any signature of call target.	aspnetcore-angular2-universal (tsconfig project)	C:\front-end\aspnetcore-angular2-universal\Client\app\app.module.ts	50	Active

@MarkPieszak
Copy link
Member

Yeah looking at it now too, not sure where that came from, worked a second ago

@MarkPieszak
Copy link
Member

Fixed now via: 61d7c0b

They changed the way you pass new Inject() now in deps, found it in the changelog. Fml 👾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants