2
votes

I added ng2-translate to my angular-cli project. It's work well in localhost but when I try to run it from ng build prod, I got 404 not found:

http://MySite/assets/i18n/en.json Failed to load resource: the server responded with a status of 404 (Not Found)

The file exist in this path, but not found by the browser.

I added this providerto app.module.ts:

providers: [ { provide: TranslateLoader, useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'), deps: [Http] }]

Maybe I should have to add some declaration to angular-cli.json? but what?

1
angular 2 - final releaseuser3292624
angular-cli: 1.0.0-beta.15 node: 6.4.0 os: win32 x64user3292624

1 Answers

3
votes

OK I found the solution. I need to add an .json file to IIS configuratin:

<staticContent>
    <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

Now the translation work well.