tomastrajan / angular-ngrx-material-starter

Angular, NgRx, Angular CLI & Angular Material Starter Project
https://tomastrajan.github.io/angular-ngrx-material-starter
MIT License
2.82k stars 919 forks source link

No text from the .json files for the language is displayed in Prod mode #387

Closed blaueeiner closed 5 years ago

blaueeiner commented 5 years ago

Minimal reproduction of the bug with instructions:

No text from the .json files for the language is displayed in Prod mode

Expected behavior:

When I start the project in Prod mode with "npm run prod" everything works but on the website there is no text from the .json language files, so I can't see any text from any .json file on the website.

Other information:

The following error occures:

[Tue Oct 09 2018 00:50:03 GMT-0400 (Eastern Daylight Time)] "GET /angular-ngrx-material-starter/assets/i18n/en.json" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"

[Tue Oct 09 2018 00:50:03 GMT-0400 (Eastern Daylight Time)] "GET /angular-ngrx-material-starter/assets/i18n/en.json" Error (404): "Not found"

[Tue Oct 09 2018 00:50:03 GMT-0400 (Eastern Daylight Time)] "GET /angular-ngrx-material-starter/assets/i18n/de.json" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"

[Tue Oct 09 2018 00:50:03 GMT-0400 (Eastern Daylight Time)] "GET /angular-ngrx-material-starter/assets/i18n/de.json" Error (404): "Not found"

First it finds the file, but then it doesn't and throws a 404 error. I dont't know why and I am wondering if nobody else got the same issue.

I would be willing to submit a PR to fix this issue:

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[ * ] No

blaueeiner commented 5 years ago

I have solved the problem!!!

In environment.prod.ts the i18nPrefix has to be "", so nothing, because otherwise the path would redirect to a folder, that doesn't exist. It would say, that the language json files are under "./dist/angular-ngrx-material-starter/assets/i18n/*.json", but they aren't :)

tomastrajan commented 5 years ago

@blaueeiner thank you for your feedback!

I guess this has to do with the fact we're using --deploy-url /angular-ngrx-material-starter/ --base-href /angular-ngrx-material-starter for deployments to GitHub and forgot to document this in the README.md...

They are related to the property i18nPrefix: '/angular-ngrx-material-starter' in environment.prod.ts. You have to adjust it to run prod build without that context path.

We probably need to adjust our prod and build:prod npm scripts so that they work and adjust documentation so people know where to look for when changing starter for their needs.

tomastrajan commented 5 years ago

@blaueeiner happy that you found out so fast, anyway we could improve experience for other users, would you be up to creating a PR with the adjustments?

santoshyadavdev commented 5 years ago

Hi @tomastrajan ,

Is it still pending, can i take this up.

tomastrajan commented 5 years ago

@santoshyadav198613 yes seems to be the case, feel free to have a look!

santoshyadavdev commented 5 years ago

Hi @tomastrajan ,

As this config will be used while deployment, we can not modify prod.ts file, should i add add one more command to run this locally in prod mode, where we can keep i18nPrefix: ''

tomastrajan commented 5 years ago

Project went through major update to Angular 8, please open new issue if the behavior persists. ( Old issue cleanup)