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

# setLanguage()

> Set the language Encore serves copy in, overriding the device language until you clear it

Sets the language Encore serves its copy and offers in. It outranks the device language on every request the SDK makes. Use it when your app has its own language picker, or when the user's app language differs from their device language.

<Note>
  New in Android SDK 2.3.0. React Native and Flutter forward it from the release that pins native 2.3.0.
</Note>

## Signature

```kotlin theme={null}
fun setLanguage(tag: String)
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `tag` | string | A well-formed BCP-47 language tag, for example `es`, `es-MX`, or `pt-BR`. The SDK normalizes its case, so `PT-br` becomes `pt-BR`, and Encore keeps only the language part, so `es-MX` serves `es`. See [Language tags](/publishers/concepts/localization#language-tags) for what is accepted |

## Behavior

* The SDK keeps the language on the device until you call [`clearLanguage()`](./clear-language), so it survives relaunches. Encore never stores it on its servers.
* It is a preference of the device, not user state, so [`reset()`](./reset) and logout leave it in place.
* When the language changes, the SDK fetches its configuration and offers again.
* Setting the language already in effect does nothing.
* An invalid tag, such as `pt_BR` or `english`, is logged and ignored. `setLanguage()` never throws, and the language already in effect stays.
* Before [`configure()`](./configure), the call logs that the SDK is not configured and does nothing.
* The language is served only when your app has it enabled. Otherwise Encore falls back to the device languages, then your app's default language. See [Localization](/publishers/concepts/localization).
* The device language is still sent as `Accept-Language`. This call adds the override that outranks it.

## Replaces the `language` attribute

Setting the language through `UserAttributes(language = ...)` is deprecated. It still works and calls `setLanguage()` for you, logging a warning once per app process, and it is removed at the next major release. The language is no longer saved with the other attributes. A language saved through the attribute on an earlier release carries over the first time the new SDK starts. Unlike `setLanguage()`, the attribute and the carry-over still accept a locale identifier and turn it into a tag, so `pt_BR` becomes `pt-BR` and `de_DE@currency=EUR` becomes `de-DE`. See [the deprecated attribute](/publishers/concepts/localization#the-language-user-attribute-is-deprecated). A language set through the attribute is stored as the same override, so it also survives `reset()`.

## Usage

Call it from your app's own language picker, and call `clearLanguage()` when the user picks "System default":

```kotlin theme={null}
fun onLanguageChanged(code: String?) {
    if (code != null) {
        Encore.shared.setLanguage(code)
    } else {
        Encore.shared.clearLanguage()
    }
}
```

## Related

* [clearLanguage()](./clear-language): go back to the device language
* [UserAttributes](./user-attributes): the deprecated `language` attribute
* [Localization](/publishers/concepts/localization): how Encore picks the language it serves


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