setusoft / silhouette-play-react-seed

A Silhouette Seed template which shows how Silhouette can be used to create a SPA with React/Redux and Play
MIT License
68 stars 21 forks source link

User language detection #47

Closed Enalmada closed 6 years ago

Enalmada commented 6 years ago

My project serves multiple languages so seeing international support in this sample really tipped me over the edge to try it. When I started it up, it was not in English despite my browser is set "english". I can see that there seems to be english message capability in the code, so I am just a bit concerned at how the language detection works for users around the world.

My Chrome browser is probably sending en-US and I am just guessing that this project is hardcoded to look for something else but I couldn't find it. Thoughts?

akkie commented 6 years ago

The default language is hard coded in the I18nModule.

In JS you can get the user language with:

navigator.language || navigator.userLanguage

So you have multiple possibilities to change the language:

Based on the selected front end implementation, an Accept-Language header must also be propagated to the backend.