Search code examples
angularangular-cling2-translate

ng2-translate does not work with angular-cli build prod


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?


Solution

  • 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.