# New option: auto-select language by HTTP header

**URL:** <https://meta.discourse.org/t/new-option-auto-select-language-by-http-header/35697>\
**Category:** Feature\
**Created:** [Novembre 17, 2015, 2:34 UTC](https://meta.discourse.org/t/new-option-auto-select-language-by-http-header/35697 "2015-11-17T14:34:24Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)\
**Post date:** [Novembre 17, 2015, 8:26 UTC](https://meta.discourse.org/t/new-option-auto-select-language-by-http-header/35697/6 "2015-11-17T20:26:55Z")

</div>

Thanks for the link, I wanted to request that, too (however it will probably not help much in my case) …

> [@simon](#):
>
> Would it work for you to have the signed-in user’s locale default to the locale from their HTTP headers, but also give them the option to set their locale for Discourse in their user preferences?

Yes, that’s exactly what I need.

> [@simon](#):
>
> The only downside that I can see for doing it this way is that until the user sets their language preferences with Discourse, the emails they get from the system will be in the forum’s default language.

Huh. What about caching the last “known” language? This obviously needs to be a different field from the user preference.  
Or better yet, have a heuristic based on how often you access the forum with a specific language? That’s increasing complexity a lot, however a simple solution could be to store an array with “known” languages and a weighting (value between 0 and 1), which is updated every time a user logs in: increase weighting for the current language and decrease it for the other ones in the array … well, not _that_ simple.

Or just cache the language the HTTP header field contains and once the user visits with a different language, show a prompt saying something like “We are having trouble identifying your main language. Please choose your preferred language from the list below:” and let that update the user preference. Then we know for sure and the user is informed / will not be surprised if the language changes because he was on vacation for too long …

---

_[View the full topic](https://meta.discourse.org/t/new-option-auto-select-language-by-http-header/35697)._
