# Set language for SSO users

**URL:** https://meta.discourse.org/t/set-language-for-sso-users/78458
**Category:** Support
**Created:** [January 19, 2018, 7:49am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458 "2018-01-19T07:49:21Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [January 19, 2018, 7:49am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/1 "2018-01-19T07:49:21Z")

</div>

Hi,

I have been trying to automatically set language for my SSO users using the Accept-Language headers. As far as I can see this should be supported by Discourse.

I enable the two options below:

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/a/5a288d9ff917938f105cfb770b4eae67b2e66d96.png)

Then with Chrome, I use an extension to set the Accept-Language:

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/7/a7def6c722e3b79f8b8b8f2f961f5c2e7a1dcd01.png)

Unfortunately, my UI stays in English. I tried different formats for accept-language (fr, Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, \*;q=0.5…) with no luck..

Any idea?

Thx,  
Seb

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 19, 2018, 4:50pm UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/2 "2018-01-19T16:50:03Z")

</div>

The set locale from header setting will not work with SSO. It only sets the locale for anonymous (not logged in) users. When SSO isn’t enabled, it will also set the locale for a user when they first register based on their language header. When SSO is enabled, users are created through a different process and the accept language header has no affect on their locale.

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [January 23, 2018, 12:39am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/3 "2018-01-23T00:39:38Z")

</div>

Thx for your answer. Is there any work around?

For instance, would it possible to use a parameter (locale) to automatically set the language?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 23, 2018, 1:00am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/4 "2018-01-23T01:00:37Z")

</div>

The only workaround I can think of would be to create a plugin that added `locale` to the [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) parameters.

---

<div class="post-metadata">

### Author: ![jeanmonod](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeanmonod/32/119952_2.png) [@jeanmonod](https://meta.discourse.org/u/jeanmonod)
#### Post date: [April 10, 2018, 10:15am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/5 "2018-04-10T10:15:05Z")

</div>

I have the exact same issue. My user interface is define at first by the browser language of my user, but once connected it fallback to the default discourse language. I just look at the code, and I’m now sure we can solve this with a plugin. Maybe we could implement this in the core. Seems some line of code into

> <https://github.com/discourse/discourse/blob/fe37ce165dff0bf269c0492ece8c5ecb3b1cc903/app/models/discourse_single_sign_on.rb#L204>

would do the trick. Can you be interested in a PR for this? The PR would be “Allow to set user locale through SSO”

---

<div class="post-metadata">

### Author: ![Muthukkumar](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Muthukkumar](https://meta.discourse.org/u/Muthukkumar)
#### Post date: [April 10, 2019, 11:03am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/6 "2019-04-10T11:03:48Z")

</div>

Hi @jeanmonod and team,  
Even I am also looking for the same request. From the SSO I want to pass the User preferred language. I am trying to achieve it with plugin but no luck for me. If you know any plugin to take care of this SSO language part please let me know.

---

<div class="post-metadata">

### Author: ![unixtam](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@unixtam](https://meta.discourse.org/u/unixtam)
#### Post date: [April 18, 2019, 8:52pm UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/7 "2019-04-18T20:52:03Z")

</div>

When I was looking for a way to set the locale via SSO, and I came across this plugin: [GitHub - liip/discourse-multilingual-support: Provide some tools to have a better multilingual support on Discourse · GitHub](https://github.com/liip/discourse-multilingual-support)

It works, but I would prefer a solution that doesn’t require a plugin.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 19, 2019, 12:48am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/8 "2019-04-19T00:48:26Z")

</div>

> [@unixtam](#):
>
> I would prefer a solution that doesn’t require a plugin.

You can now set a user’s locale with SSO without a plugin. There are two parameters you can add to the SSO payload for this: `locale` and `locale_force_update`. The `locale` parameter needs to be set to a value that Discourse will accept. Here’s the list of locales that Discourse will accept:

```plaintext
ar, bg, bs_BA, ca, cs, da, de, el, en, es, et, fa_IR, fi, fr, gl, he, hu, id, it, ja, ko, lt, lv, nb_NO, nl, pl_PL, pt, pt_BR, ro, ru, sk, sl, sq, sr, sv, sw, te, th, tr_TR, uk, ur, vi, zh_CN, zh_TW

```

The `locale_force_update` parameter is used if you wish to update the locale of an existing user via SSO.

---

<div class="post-metadata">

### Author: ![unixtam](https://avatars.discourse-cdn.com/v4/letter/u/779978/32.png) [@unixtam](https://meta.discourse.org/u/unixtam)
#### Post date: [April 19, 2019, 9:34am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/9 "2019-04-19T09:34:59Z")

</div>

Indeed I can, thanks for the heads-up! The feature seems to have been added in [Discourse 2.1](https://meta.discourse.org/t/discourse-version-2-1/86339/).

In that case I am not actually sure if the above-mentioned plugin works because the SSO parameter was already named ‘locale’. I disabled the plugin and it just continued to work.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 9, 2022, 11:48am UTC](https://meta.discourse.org/t/set-language-for-sso-users/78458/11 "2022-11-09T11:48:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
