I implemented internationalization in my angular project taking advantage of angular/localize module.
Now I have one bundle per language. If I launch the angular build I have two folders: en and it.
If I put in the browser the relative paths: http://localhost:4200/en or http://localhost:4200/it all works fine, but if I put http://localhost:4200 in my browser I got an error. This route doesn't exist and it's true. Is there a way to do it? Is there a possibility to avoid error on origin and get a redirect to correct route?
Is there a way, with angular, based on the browser language to redirect the origin http://localhost:4200 to the correct url?
Example: The default language is English, but if my browser language is setted to italian, and italian language is available in my internationalization, I have to redirect to italian app.
Use
const userLang = navigator.language || navigator.userLanguage;https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language. Then use varuserLangto set the right url.