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

## Signature

```dart theme={null}
Future<void> setLanguage(String tag)
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `tag` | `String` | A well-formed BCP-47 language tag, for example `es`, `es-MX`, or `pt-BR`. From a Flutter `Locale`, pass `locale.toLanguageTag()`, not `toString()`, which gives `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 completes the returned `Future` with an `ArgumentError`, before anything reaches the native SDK. See [Errors](#errors).
* 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 |
| - | - |
| `ArgumentError` | `tag` is not a well-formed language tag, for example `'pt_BR'` or `'english'`. Use `'pt-BR'` and `'en'` |

The error arrives through the returned `Future`, and nothing changes. Catch it where you await the call, or with `catchError`. A call you do not await still reports it, as an unhandled `Future` error.

## Replaces the `language` attribute

Setting the language through `EncoreUserAttributes(language: ...)` is deprecated, on both the field and the constructor parameter. 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":

```dart theme={null}
Future<void> onLanguageChanged(String? code) async {
  if (code != null) {
    await Encore.shared.setLanguage(code);
  } else {
    await Encore.shared.clearLanguage();
  }
}
```

## Related

* [clearLanguage()](./clear-language): go back to the device language
* [EncoreUserAttributes](./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.