# Anonymous user language selector for Discourse

**URL:** https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014
**Category:** Feature
**Created:** [2017年二月6日 22:17 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014 "2017-02-06T22:17:08Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:17 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/1 "2017-02-06T22:17:08Z")

</div>

Hi!

First of all, thanks for discourse. It’s really user friendly! 😍

We’ve set up a discourse instance so people in [Catalonia](https://en.wikipedia.org/wiki/Catalonia) can discuss the principles and statutes of a newly born political party.

Language spoken in this region is very equally distributed between Catalan and Spanish, see [here](https://en.wikipedia.org/wiki/Languages_of_Catalonia#Statistics) for a reference. It’s also a pretty sensitive issue. Most of the people can understand both languages, but feel unconfortable when they are not given a choice.

So in this context, it’s really compulsory to have a language choice. The fact that users can optionally select a language preference in their profile and that the browser language can be optionally autoselected as the site language helps a lot but doesn’t completely solve the issue: anonymous users can’t select their language.

I guess the same situation happens in other places (Quebec, for example?). In particular, in Spain it would happen in some another regions that have two official languages as well (Galicia, Valencian Community, Basque Country…), which amount to around 40% of the total population (~15million people).

I’d like a simple way of enabling a language choice in Discourse. We’ve implemented this through a new optional setting that allows admins to select a number of languages which will be displayed in the main menu allowing changing the UI language.

I’d like to ask whether there’s interest in this feature so I can open a PR to the discourse repository.

Thanks!!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年二月6日 22:24 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/2 "2017-02-06T22:24:36Z")

</div>

> [@deivid-rodriguez](#):
>
> I’d like to ask whether there’s interest in this feature so I can open a PR to the discourse repository.

As a plugin 100% absolutely 🙂

As a piece of core that is default disabled, I think it fits OK as long as it does not introduce any slowness and is off by default.

Can you post some examples of how the UI looks for anon, and how you configure this?

---

<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: [2017年二月6日 22:33 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/3 "2017-02-06T22:33:33Z")

</div>

For anon this will be _incredibly_ difficult due to caching.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年二月6日 22:35 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/4 "2017-02-06T22:35:52Z")

</div>

> [@codinghorror](#):
>
> For anon this will be incredibly difficult due to caching.

Yeah, you would probably need to set a cookie on the browser if anonymous makes a change to the selector.

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:37 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/5 "2017-02-06T22:37:57Z")

</div>

Of course, you can see the selector here: [https://fem.unpaisencomu.cat](https://fem.unpaisencomu.cat).

And this is a screenshot of the UI:

 ![](https://global.discourse-cdn.com/meta/original/3X/9/c/9ca73933c522112a308bde7a13884b0f3bd9bc78.png)

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:38 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/6 "2017-02-06T22:38:51Z")

</div>

> [@sam](#):
>
> Yeah, you would probably need to set a cookie on the browser if anonymous makes a change to the selector.

Yes, that’s what we do.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年二月6日 22:42 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/7 "2017-02-06T22:42:19Z")

</div>

> [@deivid-rodriguez](#):
>
> fem.unpaisencomu.cat

I am not sure it is working for me, are you sure you have a bypass in anonymous cache that normalizes redis cache based off this cookie?

Also, this is hidden in the hamburger, odds are TINY anonymous users will find this.

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:47 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/8 "2017-02-06T22:47:37Z")

</div>

No, we have none of that… The selector is not working for anonymous users at all… 😳 We’ll have to fix that.

The fact that it’s hidden in the hamburguer menu is because it was the easiest place for me to add it. I had never read a single line of ember in my life, so I had a lot of trouble adding it.

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:49 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/9 "2017-02-06T22:49:30Z")

</div>

Of course totally up for improving on what we now have if you’re interested in the feature. Well, more than improving… making it actually work 😆

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [2017年二月6日 22:51 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/10 "2017-02-06T22:51:13Z")

</div>

Is the `Accept-Language` HTTP request header not an option here?

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月6日 22:53 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/11 "2017-02-06T22:53:41Z")

</div>

Yes, we have it enabled as well, but that setting is not 100% accurate (say, catalan speaking user connecting from her work’s brower which is set to Spanish). We want to always let the user override the language they are “given”.

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月7日 13:16 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/12 "2017-02-07T13:16:33Z")

</div>

> [@sam](#):
>
> Also, this is hidden in the hamburger, odds are TINY anonymous users will find this.

To be honest, I had the same feedback from our clients. Although the reason to put it there was just to simplify the implementation, after a second thought it does not seem like a bad place to me. This is a very unusual action (not a lot of users will actually need it, and in any case, it will be used at most once by most users). So it feels bad that it takes a permanent space of the screen. As per the difficulty of finding it… well, if I proactively look for the option, I think the hamburger is the first place I would try.

> [@sam](#):
>
> I am not sure it is working for me, are you sure you have a bypass in anonymous cache that normalizes redis cache based off this cookie?

I just tried my initial implementation locally and it works. So I assumed it would work in our beta/productions environments as well… my bad :sadpanda: … Is the fact that it works locally something that you would expect, @sam?

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月7日 13:55 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/14 "2017-02-07T13:55:06Z")

</div>

> [@codinghorror](#):
>
> For anon this will be incredibly difficult due to caching.

I guess that’s what’s biting me… and has to do with:

```
~/Code/discourse $ ag caching config/environments/development.rb 
13: # Show full error reports and disable caching
15: config.action_controller.perform_caching = false
49: config.enable_anon_caching = false

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年二月7日 13:58 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/15 "2017-02-07T13:58:00Z")

</div>

Its this code:

> <https://github.com/discourse/discourse/blob/96183dbf6b5c4688507f3fa4148c681b8d4f552f/lib/middleware/anonymous_cache.rb>

---

<div class="post-metadata">

### Author: ![deivid-rodriguez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deivid-rodriguez/32/121109_2.png) [@deivid-rodriguez](https://meta.discourse.org/u/deivid-rodriguez)
#### Post date: [2017年二月7日 14:09 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/16 "2017-02-07T14:09:03Z")

</div>

Thanks! That’s very helpful 🙂. Now I understand better your previous question:

> [@sam](#):
>
> are you sure you have a bypass in anonymous cache that normalizes redis cache based off this cookie?

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2025年八月15日 03:03 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/17 "2025-08-15T03:03:08Z")

</div>

这现在已在

> [@Content Localization - Manual and Automatic with Discourse AI](https://meta.discourse.org/t/content-localization-manual-and-automatic-with-discourse-ai/370969#p-1797766-setting-locales-that-your-community-supports-3):
>
> In this topic, we will walk you through the Content Localization features and how to enable them. The features are split into two parts: What is available by default in Discourse; and Discourse AI for automatic translations. For quick access to the relevant sections, use the wiki headings backhand_index_pointing_right:t2Localizing Your Community’s Content An updated version of Discourse (3.5.0.beta7-dev) gives you access to several localization features available for configuration at: \<y…

中完成

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2025年八月15日 03:03 UTC](https://meta.discourse.org/t/anonymous-user-language-selector-for-discourse/57014/18 "2025-08-15T03:03:11Z")

</div>


