> ## Documentation Index
> Fetch the complete documentation index at: https://sleekplan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set the visitor's language

> Show the widget, the portal and the iframe in your user's language: pass it in the SSO token, switch it at runtime with $sleek.setLanguage(), pick it with the URL, or store it over the REST API

A workspace offers its default language plus the additional languages its admins add under [**Settings → Languages**](https://app.sleekplan.com/settings/languages). The widget, the portal and the iframe show every visitor one of those languages: the interface, the workspace's own texts, and the posts, comments and changelog entries, translated. This page shows how your product tells Sleekplan which language a user reads. How admins set up languages and translations is explained in the [Help Center](https://sleekplan.com/help/portal-widget/languages.md).

## How the language is chosen

Sleekplan only picks a language the workspace offers. A source that names any other language is skipped, and the next one counts.

**In the widget**

1. The language set with [`$sleek.setLanguage()`](#switch-the-language-at-runtime) on the current page load.
2. The signed-in user's language, stored on their account.
3. The browser's languages, in the browser's order, when the workspace has **Detect the browser language** on.
4. The workspace's default language.

**On the portal and in the iframe**

1. The signed-in user's language, stored on their account.
2. The language in the URL path, such as `/de/feedback`.
3. The language the visitor picked in the portal's language menu.
4. The browser's `Accept-Language` header, when **Detect the browser language** is on.
5. The workspace's default language.

The stored language of a user comes from your [SSO token](#pass-the-language-with-single-sign-on), from `setLanguage()`, from the REST API, from the user's own pick in their account settings, or from an admin on the customer's page. A user who has none yet gets the language they were using the board in when they sign in or sign up.

## Language codes

Every input that takes a language accepts the codes below and the usual tags and locales, in any case and with `-` or `_`: `de-AT` and `de_DE` mean German, `pt` and `pt-PT` mean Portuguese (Brazil), `zh-Hant`, `zh-TW` and `zh-HK` mean Chinese (traditional), `zh`, `zh-Hans` and `zh-CN` mean Chinese (simplified), `cs` means Czech, and `nb` and `nn` mean Norwegian. A value that names none of the 24 languages is ignored.

Stored values and the REST API always use the code. The portal's URL uses the URL segment, which differs only for Czech and Chinese (traditional).

| Language | Code | URL segment |
| - | - | - |
| English | `en` | `en` |
| German | `de` | `de` |
| French | `fr` | `fr` |
| Spanish | `es` | `es` |
| Portuguese (Brazil) | `pt-br` | `pt-br` |
| Chinese (traditional) | `cn` | `zh-hant` |
| Chinese (simplified) | `zh-cn` | `zh-cn` |
| Polish | `pl` | `pl` |
| Czech | `cz` | `cs` |
| Indonesian | `id` | `id` |
| Ukrainian | `uk` | `uk` |
| Dutch | `nl` | `nl` |
| Norwegian | `no` | `no` |
| Japanese | `ja` | `ja` |
| Vietnamese | `vi` | `vi` |
| Italian | `it` | `it` |
| Greek | `el` | `el` |
| Hungarian | `hu` | `hu` |
| Korean | `ko` | `ko` |
| Thai | `th` | `th` |
| Russian | `ru` | `ru` |
| Swedish | `sv` | `sv` |
| Turkish | `tr` | `tr` |
| Arabic | `ar` | `ar` |

Arabic is shown right to left, in the widget, on the portal and in emails.

## Pass the language with single sign-on

If your users sign in through [single sign-on](https://sleekplan.com/docs/authentication/single-sign-on.md), add a `language` claim to the token. Sleekplan stores it on the user at every sign-in, replacing the language stored before, so your product stays the source of truth.

```javascript theme={"system"}
const jwt = require('jsonwebtoken');

function createSSOToken(localUser) {
  return jwt.sign({
    mail: localUser.mail,
    id: localUser.id,
    name: localUser.name,
    // The language your product shows this user: a code or a tag
    language: localUser.locale, // e.g. 'de' or 'pt-BR'
  }, 'PRIVATE_SSO_KEY', { algorithm: 'HS256' });
}
```

* Put `language` **inside** the token. A `language` passed next to the token, outside it, is ignored.
* Leave the claim out to keep the stored language as it is. An empty or `null` claim removes it.
* The claim counts at sign-in, and the widget signs a user in when it has no session yet. A language change in your product shows up at the user's next sign-in. To switch at once, also call [`$sleek.setLanguage()`](#switch-the-language-at-runtime).
* A user who picks another language in their Sleekplan account settings keeps it until their next SSO sign-in.
* The same claim works for the portal and the iframe when you pass the token with `?sso=`.

## Switch the language at runtime

`$sleek.setLanguage(code)` sets the widget's language for the current page load. Use it to keep the widget in step with your product's own language setting.

```javascript theme={"system"}
// A code or a tag
$sleek.setLanguage('de');
$sleek.setLanguage('pt-BR');

// Follow your page's language once the SDK is ready
document.addEventListener('sleek:init', function () {
  $sleek.setLanguage(document.documentElement.lang);
});
```

**code** `string` *required*

One of the 24 languages, as a code or a tag (see [Language codes](#language-codes)).

**return** `boolean`

`true` when the value names one of the 24 languages. `false` otherwise, and then nothing changes.

* **Before and after opening.** Called before the widget is opened, the language is applied as the widget loads, so its first screen is already in it. While the widget is open it switches in place: lists and the open post load again, and text the visitor has typed stays.
* **Per page load.** The SDK keeps the value in memory only. Call it on every page load, or let the stored language take over.
* **Saved for signed-in users.** For a signed-in user, the widget also stores the language on their account, so the portal and their emails follow it.
* **Only languages the workspace offers are shown.** For any other language the widget stays in the language it would show otherwise. A signed-in user's account still stores it, and it applies as soon as the workspace adds that language.
* **The launcher and popups follow.** The launcher's label switches to the workspace's text for that language, and popups that an admin limited to some languages use it too.
* **Widget only.** The portal and the iframe take their language from the URL and the signed-in user, never from this method.

## Pass the language without single sign-on

`$sleek.setUser()` and `window.SLEEK_USER` take a `language` field. Without a `token`, it is stored when `setUser()` signs the user in on its own: on a public board that asks for no email confirmation and doesn't force single sign-on. With a `token`, put the language in the token instead.

```javascript theme={"system"}
$sleek.setUser({
  mail: 'jane@example.com',
  name: 'janesmith',
  language: 'fr',
});
```

See [User setup](https://sleekplan.com/docs/sdk/user-setup.md) for the other fields.

## Choose the language in the iframe or on the portal

The first segment of the path picks the language. The default language has no segment.

```html theme={"system"}
<!-- The board in German -->
<iframe src="https://embed-{PRODUCT_ID}.sleekplan.app/de/"></iframe>

<!-- The changelog in Chinese (traditional) -->
<iframe src="https://embed-{PRODUCT_ID}.sleekplan.app/zh-hant/changelog"></iframe>
```

The same paths work on your portal's own address, such as `https://feedback.yourcompany.com/fr/feedback/48121`.

* A segment of a language the workspace doesn't offer redirects to the path without it (302), and the default language's own segment redirects there too (301).
* Without a segment, a visitor who picked a language in the menu, or whose browser asks for one the workspace offers, is redirected to that language.
* A signed-in user is moved to their own language, whatever the path says.

> [!NOTE]
>
> The iframe runs on a third-party domain inside your page. A browser that blocks third-party cookies forgets a choice made in the language menu at the next load. The path you set and the browser's language still work.

## Read and write it over the REST API

End-user objects carry `data_language`: the stored code, or `null` when the user has none. [Create an end-user](https://sleekplan.com/api-reference/user/create-an-end-user.md) and [Update an end-user](https://sleekplan.com/api-reference/user/update-an-end-user.md) accept it:

```bash theme={"system"}
curl -X PUT https://api.sleekplan.com/v1/user/91422 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "data_language": "de" }'
```

A tag such as `de-AT` is stored as its code, a value that names no language is ignored, and `null` or an empty string removes the stored language. The `user.create` and `user.update` [webhook](https://sleekplan.com/docs/webhooks.md) payloads carry `data_language` too.

> [!NOTE]
>
> The REST API, webhooks and the [MCP server](https://sleekplan.com/docs/mcp-server.md) always return the original text of posts, comments and changelog entries, never a translation.

> [card] [Single sign-on](https://sleekplan.com/docs/authentication/single-sign-on.md)
>
> Generate the token that carries the `language` claim.

> [card] [User setup](https://sleekplan.com/docs/sdk/user-setup.md)
>
> Identify users with `$sleek.setUser()`.

> [card] [Embed in an iframe](https://sleekplan.com/docs/install/iframe.md)
>
> Embed the portal in a page or a mobile webview.

> [card] [Languages in the Help Center](https://sleekplan.com/help/portal-widget/languages.md)
>
> How admins add languages and edit translations.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.