Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Language js package in dist Version #271

Open
carlosfelipe29 opened this issue Mar 22, 2019 · 3 comments
Open

Load Language js package in dist Version #271

carlosfelipe29 opened this issue Mar 22, 2019 · 3 comments

Comments

@carlosfelipe29
Copy link

Hi everybody,

My problem happen in the dist Version, when I upload the folder to my subdirectory in my web hosting.
When I run localhost:4200 everything works perfectly, all tthe links; but whe I generated the dist version not so well,

First of all, my app run over a Directory (subfolder: URL/myfolder), in this way I run:

ng build --prod --base-href /myfolder/ --deploy-url /myfolder/

After I uploaded the dist folder, occur the error:
"error load URL/assets/i18n/en.json"
"error load URL/assets/i18n/es.json"
So, The language buttons does not work,

What kind of changes I need to do, in order to havethis files working?, I have tried modify some files with the word "myfolder" angular.json but not succeded.

My second problem, is simple, When I refresh the website, shows and 404 error, I read about it , and It supose will fix using the --base-href attribute, due to the browser try to load URL/somoething and not URL/myfolder/index.html ?
how can I fix this too?

I appreciate your help.

@nkmdev
Copy link
Collaborator

nkmdev commented Mar 22, 2019

For language issue just look at the package.json file
For 404 issue use url rewrite and redirect it to index.html page
We do have configuration file for apache

@carlosfelipe29
Copy link
Author

Hi, appreciate your answer,

the problem would be this:
the Browser engine want to load URL/assets/i18n/es.json:1 Failed but behind the url all the resources are loading from URL/myfolder/assets/i18n/en.json.

in For language issue just look at the package.json file
in this part:
"@ngx-translate/core": "11.0.0",
"@ngx-translate/http-loader": "4.0.0",

I think maybe I have to change something in "configurations": { "production": {... in angular.json

I doubt about the option to compile: --deploy-url /myfolder/ because it is applied to the assets/images
assets/css but not for assets/i18n

thank you

@nkmdev
Copy link
Collaborator

nkmdev commented Mar 22, 2019

For q quick fix you can use env variable
For production use full path(sub folde path + assets/i18n/en.json)
In development mode use path as it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants