1

I'm trying to implement ngx-translate from this tutorial:

Locally when I run the angular app using npm start it's working fine. But when I want to use custom subdir like this: ng build --output-path angular --base-href=/angular/ and to deploy it on Apache server the file is not found.

File is located under src\assets\i18n\en.json

I get multiple errors like this:

message: "Http failure response for http://123.123.123.123/assets/i18n/en.json: 404 Not Found"

With some luck I managed to solve this using this code:

export function HttpLoaderFactory(httpClient: HttpClient) {
  return new TranslateHttpLoader(httpClient, '/angular/assets/i18n/', '.json');
}

But now when I run locally using ng start the files is not found.

Do you know how this can be fixed in both cases?

2
  • what version of angular do you use? Commented Apr 7, 2020 at 21:23
  • I use Angular: 9.1.0 Commented Apr 7, 2020 at 21:29

1 Answer 1

1

you must change in relative path

export function HttpLoaderFactory(httpClient: HttpClient) {
  return new TranslateHttpLoader(httpClient, 'assets/i18n/', '.json');
}
Sign up to request clarification or add additional context in comments.

1 Comment

I have one additional question: stackoverflow.com/questions/61070841/… Have you faced this before?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.