> For the complete documentation index, see [llms.txt](https://docs.userlane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.userlane.com/developer-reference/userlane-language-detection.md).

# Userlane language detection

Language detection priorities and how to set the language explicitly with the lang command.

## About language detection

Userlane detects the language of the application and of the user's browser, then matches the user's language preference.

## Detection priorities

Userlane resolves the language in this order:

1. The language set by the `lang` command in the application.
2. The language settings in the Userlane Portal.
3. The HTML `lang` attribute.
4. Meta information.
5. The browser language.
6. The default language defined in the Userlane Portal.

{% hint style="info" %}
Where the application hard-codes the language tag in its HTML, contact the customer value team. In those cases the detection can be adjusted so that the end user's browser language takes priority over the application's language.
{% endhint %}

## Define a specific language

To make Userlane always use the same language as the application, set the language explicitly with the `lang` command. This is useful where the application offers a language setting but does not declare its language in the standard HTML `lang` attribute.

```javascript
// set the language of Userlane
Userlane('lang', 'language_code');
```

The language code is either a two-letter code, such as `en` or `de`, or a five-letter code, such as `en-us` or `en-gb`.

## Best practices

**Match the language codes exactly.** The code used in the command has to match the language key that was used when the language was created in the Portal.

**Publish the language first.** A language passed via the `lang` command has to exist and be public in the Userlane Portal. Otherwise Userlane falls back to the default language.

**Check which language the Editor opens in.** The Editor opens in the last language worked in. That makes it easy to continue editing, but it also means edits can land in the wrong language after switching, and it explains why the Assistant appears in a particular language.

## Relevant articles

{% content-ref url="/pages/cg5g8Xki3RfJej7DhphW" %}
[Content operations](/assistance/content-operations.md)
{% endcontent-ref %}

{% content-ref url="/pages/JaoydeD5UPCYFS9NuupA" %}
[Quick reference of commands](/developer-reference/quick-reference-of-commands.md)
{% endcontent-ref %}

{% content-ref url="/pages/brm1JWKM3yHqhKU1n5G2" %}
[A tour of the Editor](/assistance/a-tour-of-the-editor.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.userlane.com/developer-reference/userlane-language-detection.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
