When user locale is `default`, should use HTTP `accept-language`

Currently, if a user is anonymous, the locale is take from the HTTP accept-language:

https://github.com/discourse/discourse/blob/master/app/controllers/application_controller.rb#L212-L223

This does not happen for logged in users.

For new users who first came to the site, their language is set to the site default. This may not be optimal, as the user can be from any world region.

It would be nice to detect whether user.effective_locale is default, and if so set it to locale_from_header. This way, new users will automatically see the site from his/her own language.

They can, of course, change it themselves in their profile, but not every new user knows how to do this, they being “new”. And language is such a significant part of the user experience.

The rules are different for anon because it becomes a caching nightmare that ruins performance. I believe @sam has a topic on that he can point you to.

I suspected that it is something similar…

However, if the site is going to have multi-lingual users, then eventually many locales are going to be hit, and you mind as well bite the bullet on day one…

What I’m bringing up is first-impression user experience. A Spanish user these days will expect to surf to a site and see a Spanish version (if available) automatically. He/she won’t expect to need to go into the profile to set language.

It is quite difficult. Feel free to submit a pull request if you feel this is something that needs to be done.

This one:

Should have searched more before jumping in and creating a new topic. :sweat_smile:

3 Likes