> ## 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 the React Native SDK release that pins native 2.3.0.
</Note>

## Signature

```typescript theme={null}
setLanguage(tag: string): Promise<void>
```

## 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.
* An invalid tag rejects the returned `Promise` before anything reaches the native SDK. See [Errors](#errors).
* A failure inside the native SDK logs a warning, and the `Promise` still resolves, like every other Encore call. The same happens when a newer JavaScript bundle runs on an app binary built before this release, for example after an over-the-air update. When the native module is not linked, for example in Expo Go, the call resolves 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.

## Errors

| Error | When |
| - | - |
| `RangeError` | `tag` is not a well-formed language tag, for example `'pt_BR'` or `'english'`. Use `'pt-BR'` and `'en'` |
| `TypeError` | `tag` is not a string |

Both reject before the call reaches the native SDK, so nothing changes.

## Replaces the `language` attribute

Setting the language through the `language` attribute is deprecated. It still works and calls `setLanguage()` for you, logging a warning once, and it is removed at the next major release. 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":

```typescript theme={null}
import Encore from '@encorekit/react-native';

async function onLanguageChanged(code: string | null) {
  if (code) {
    await Encore.setLanguage(code);
  } else {
    await Encore.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.