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

**URL:** https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770
**Category:** Feature
**Created:** [September 26, 2017, 2:25am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770 "2017-09-26T02:25:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [September 26, 2017, 2:25am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/1 "2017-09-26T02:25:31Z")

</div>

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

> <https://github.com/discourse/discourse/blob/main/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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 26, 2017, 2:38am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/2 "2017-09-26T02:38:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [September 26, 2017, 2:41am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/3 "2017-09-26T02:41:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 26, 2017, 2:42am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/4 "2017-09-26T02:42:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [September 26, 2017, 2:43am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/5 "2017-09-26T02:43:11Z")

</div>

This one:

> [@Variable default interface language for new users](https://meta.discourse.org/t/variable-default-interface-language-for-new-users/33741):
>
> Hey guys, New Discourse user here, but super impressed and excited about what a great product it is. I am developing a forum that will be multilingual (Arabic/English/German). Most users will be extremely limited in the other languages, basically I don’t want to expect a German/English speaker to be able to read Arabic script, and vice versa. I also don’t want to rely too much on their computer skills—want to make this as easy as possible. Is there a way that I can provide a separate URL that …

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 26, 2017, 2:47am UTC](https://meta.discourse.org/t/when-user-locale-is-default-should-use-http-accept-language/70770/6 "2017-09-26T02:47:16Z")

</div>


