0

I am developing an Angular + Electron project. In that I am using angular-translate functionality and I have an en.json file in the /src/assets/i18n folder. Everything works good on the browser.

But when I run electron build, it is failed to load the en.json file. It is showing the error

Failed to load resource: net::ERR_FILE_NOT_FOUND

and it is referring to the url

file:///assets/i18n/en.json

The en.json is actually located in dist/myProject/assets/i18n directory.

How can I fix this issue? I tried adding

src/assets/i18n

in asssets in angular.json file. Then also there is no change in the result. How can I fix this? Any help could be appreciated.

Arun
  • 3,640
  • 7
  • 44
  • 87

3 Answers3

1

I have fixed this issue. I added below code in app.module.ts

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Arun
  • 3,640
  • 7
  • 44
  • 87
0

Have you added this folder as a resource in your config? I'm referring to this answer.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Heisenbug
  • 951
  • 6
  • 25
0

The Electron app use the absolute path "./" after build. You must check the translate config to load the language files from the absolute path. I have changed "/assets/i18n" to "./assets/i18n" and all works fain.