question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An issue with loading JSON (language resource) files when the angular-cli build is used

See original GitHub issue

I found an issue with loading JSON (language resource) files when the angular-cli build is used and the whole application is put under a subfolder and base href is changed. Currently, 404 Not Found error is displayed since the library tries to access the file from (<domain>/assets/i18n/en.json) instead of the (<domain>/subfolder/assets/i18n/en.json) even though the base href is updated accordingly. The application works fine if I put it in the root folder.

In my opinion, the library should try to prepend the base href in all cases. Just a suggestion. Looking forward to resolving it.

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:15

github_iconTop GitHub Comments

25reactions
julianpoempcommented, Mar 13, 2017

in app.module.ts make sure that you use this HttpLoaderFactory function:

export function HttpLoaderFactory(http: Http) {
	return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}

that fixed this issue for me.

3reactions
lchimarucommented, Jul 17, 2017

I had the same issue, but changing "assets": [ "assets", "favicon.ico" ], to "assets": [ "assets/", "favicon.ico" ], helped me solved it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

en.json not found error on angular electron - Stack Overflow
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...
Read more >
3+ Ways for Reading Local JSON Files with Angular 15
In this post, we'll show you three different methods to read local JSON files in your Angular 15 application, each with an example....
Read more >
Work with translation files - Angular
To extract the source language file, complete the following actions. Open a terminal window. Change to the root directory of your project. Run...
Read more >
How to translate your Angular app with ngx-translate
1. Add ngx-translate to your Angular application 2. Set up the TranslateService in your app.module.ts 3. Create your main language translation file (in...
Read more >
Implementing multi-language Angular applications rendered ...
A few recent comments on the same issue #754 suggest importing the contents of JSON files straight into the file which defines our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found