# איך להגדיר שפה למשתמשי SSO

**URL:** https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332
**Category:** SSO
**Created:** [31 באוגוסט,‏ 2023,‏ 11:01am UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332 "2023-08-31T11:01:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ankur\_Tyagi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ankur_tyagi/32/323644_2.png) [@Ankur\_Tyagi](https://meta.discourse.org/u/Ankur_Tyagi)
#### Post date: [31 באוגוסט,‏ 2023,‏ 11:01am UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/1 "2023-08-31T11:01:46Z")

</div>

how can I set the language for a logged in user using sso. I tried to use “locale” key if user is accessing for the first time, it did not work. I believe the “locale” key works if user is anonymous.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [31 באוגוסט,‏ 2023,‏ 11:07am UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/2 "2023-08-31T11:07:26Z")

</div>

Hello @Ankur_Tyagi👋🏻 welcome to Meta 🙂

This post should help. there are two parameters you need.

> [@Set language for SSO users](https://meta.discourse.org/t/set-language-for-sso-users/78458/8):
>
> 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: 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…

---

<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: [1 בספטמבר,‏ 2023,‏ 3:26pm UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/4 "2023-09-01T15:26:32Z")

</div>

> [@Ankur\_Tyagi](#):
>
> I tried it with a new user as well as updating locale for an existing user, but it did not work.

For a _new_ user who has never logged into Discourse before, it should work if the `locale` parameter is set in the payload the first time the user logs into the site. For example, using the npm docs that you linked to:

```plaintext
var userparams = {
	// Required, will throw exception otherwise
	"nonce": nonce,
	"external_id": "some user id here",
	"email": "some user email",
	// Optional
	"username": "some username",
	"name": "some real name",
    "locale": "es"
};

```

For an _existing_ user who already has an account on Discourse, you will need to add the `locale_force_update` parameter to the `userparams` and set it to `true`. I think that for your case you could include the `locale_force_update` param both when you create a new user and when you update a user:

```plaintext
var userparams = {
	// Required, will throw exception otherwise
	"nonce": nonce,
	"external_id": "some user id here",
	"email": "some user email",
	// Optional
	"username": "some username",
	"name": "some real name",
    "locale": "es",
    "locale_force_update": true
};

```

> [@Ankur\_Tyagi](#):
>
> I am looking for a solution for logged in users.

Unfortunately, to _update_ the locale, or any other attributes via the [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) payload, the user will have to log out of Discourse, and then log back in again. This means that it is unlikely that the user will get the updated locale right away. There is a workaround for this, but I do not think it is handled by the discourse-sso npm package. To update a user via [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) without requiring them to log out and log back into Discourse, you need to make a call to the `sync_sso` route. Details about that are here: [Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-discourseconnect-user-data-with-the-sync-sso-route/84398).

If you are having trouble getting the locale set correctly for new users, or for users who log out and back in after adding the locale parameters, try enabling the `verbose discourse connect logging` Discourse site setting. That will allow you to see the parameters that are being sent to Discourse from your site’s `/logs` page (found at Admin / Logs / Error Logs.)

---

<div class="post-metadata">

### Author: ![Ankur\_Tyagi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ankur_tyagi/32/323644_2.png) [@Ankur\_Tyagi](https://meta.discourse.org/u/Ankur_Tyagi)
#### Post date: [4 בספטמבר,‏ 2023,‏ 9:18am UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/5 "2023-09-04T09:18:26Z")

</div>

Hello @Lilly  
Thanks for your reply.  
I tried it with a new user as well as updating locale for an existing user, but it did not work. I think it only works for anonymous users case. I am looking for a solution for logged in users.

It would be helpful if you can review the setup configuration details below, may be there is something I need to update to fix it, not sure.

1. Discourse forum version: **Discourse 3.2.0.beta1-dev**
2. JS package used for sso: **discourse-sso ( version: 1.0.5 )**
3. Discourse package link: [discourse-sso - npm](https://www.npmjs.com/package/discourse-sso)

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [4 בספטמבר,‏ 2023,‏ 11:46pm UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/7 "2023-09-04T23:46:58Z")

</div>

> [@Ankur\_Tyagi](#):
>
> Hello @Lilly  
> Thanks for your reply.  
> I tried it with a new user as well as updating locale for an existing user, but it did not work. I think it only works for anonymous users case. I am looking for a solution for logged in users.
> 
> It would be helpful if you can review the setup configuration details below, may be there is something I need to update to fix it, not sure.
> 
> 1. Discourse forum version: **Discourse 3.2.0.beta1-dev**
> 2. JS package used for sso: **discourse-sso ( version: 1.0.5 )**
> 3. Discourse package link: [discourse-sso - npm](https://www.npmjs.com/package/discourse-sso)

Hi @Ankur_Tyagi I am sorry you are still having problems. Did you review Simon’s advice using the `locale_force_update` parameter? I think everything I know about SSO is from @simon 🙂

> [@simon](#):
>
> For an _existing_ user who already has an account on Discourse, you will need to add the `locale_force_update` parameter to the `userparams` and set it to `true`. I think that for your case you could include the `locale_force_update` param both when you create a new user and when you update a user:

I would carefully go through this information @simon posted as well as the official [DiscourseConnect SSO How-To](https://meta.discourse.org/t/setup-discourseconnect-official-single-sign-on-for-discourse-sso/13045) that has been linked.

> [@simon](#):
>
> Unfortunately, to _update_ the locale, or any other attributes via the [DiscourseConnect](https://meta.discourse.org/t/13045) payload, the user will have to log out of Discourse, and then log back in again. This means that it is unlikely that the user will get the updated locale right away. There is a workaround for this, but I do not think it is handled by the discourse-sso npm package. To update a user via [DiscourseConnect](https://meta.discourse.org/t/13045) without requiring them to log out and log back into Discourse, you need to make a call to the `sync_sso` route. Details about that are here: [Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-discourseconnect-user-data-with-the-sync-sso-route/84398).
> 
> If you are having trouble getting the locale set correctly for new users, or for users who log out and back in after adding the locale parameters, try enabling the `verbose discourse connect logging` Discourse site setting. That will allow you to see the parameters that are being sent to Discourse from your site’s `/logs` page (found at Admin / Logs / Error Logs.)

The verbose [discourse connect](https://meta.discourse.org/t/13045?silent=true) logging setting and logs can help you troubleshoot this:

 ![verbose_settings](https://global.discourse-cdn.com/meta/original/4X/b/5/6/b56507ed1c80b76b3b698710800248b21eff88e6.png)

---

<div class="post-metadata">

### Author: ![Ankur\_Tyagi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ankur_tyagi/32/323644_2.png) [@Ankur\_Tyagi](https://meta.discourse.org/u/Ankur_Tyagi)
#### Post date: [13 בספטמבר,‏ 2023,‏ 9:02am UTC](https://meta.discourse.org/t/how-to-set-language-for-sso-users/277332/8 "2023-09-13T09:02:10Z")

</div>

Thanks @Lilly, i will try this solution
