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

# App language

*Amply SDK 0.14.0+.*

Amply shows sheets, stories and mini-apps in the language your app is showing, and lets campaigns target by that language. This page explains where Amply gets that language, how to tell it yourself, and which translation a user ends up seeing.

**Use this when** your app has more than one language — especially when the user picks the language inside your app, or when your translations live in JavaScript (React Native, Expo). **You can skip it** when your app has one language, or when it relies only on the system's per-app language setting: Amply picks that up on its own.

## App language and device language

Amply keeps two separate values.

|             | Device language                                 | App language                                                                        |
| ----------- | ----------------------------------------------- | ----------------------------------------------------------------------------------- |
| What it is  | The language set in the phone's settings        | The language your app's screens are in                                              |
| Who decides | The user, in system settings                    | Your app (or the system's per-app language setting)                                 |
| Used for    | Values in campaign links (`{@device.language}`) | Which translation of a sheet or story is shown, the **App language** targeting rule |

Amply never changes the device language. When your app tells Amply its language, only the app language changes.

## Where the app language comes from

Amply uses the first of these that gives an answer:

1. **The language your app set** with `setAppLanguage`. It is remembered across launches until you change it or pass `null`.
2. **The language the system chose for your app.**
   * iOS: the localization iOS picked from the ones your app ships, including the per-app choice in **Settings → your app → Language**. Used only when your app ships at least two localizations.
   * Android: the per-app language (Android 13+ app language settings, or AndroidX AppCompat's `setApplicationLocales`).
3. **The device language.**

{% hint style="info" %}
**React Native and Expo apps should call `setAppLanguage`.** These apps usually translate in JavaScript and ship a single iOS localization, so iOS cannot know which language the user picked. Without the call, Amply falls back to the device language.
{% endhint %}

## Telling Amply the app language

Call `setAppLanguage` when your app starts and every time the user switches language. Pass `null` to go back to automatic detection.

{% tabs %}
{% tab title="iOS (Swift)" %}

```swift
amply.setAppLanguage(tag: "pt-BR")

// Back to automatic detection
amply.setAppLanguage(tag: nil)
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
amply.setAppLanguage("pt-BR")

// Back to automatic detection
amply.setAppLanguage(null)
```

{% endtab %}

{% tab title="React Native (TS)" %}

```ts
import Amply from '@amplytools/react-native-amply-sdk';
import i18n from './i18n'; // i18next, react-i18next, …

Amply.setAppLanguage(i18n.language);
i18n.on('languageChanged', (lng) => Amply.setAppLanguage(lng));
```

{% endtab %}
{% endtabs %}

You can also pass it when you initialize the SDK, so the very first sheet is already in the right language: the `appLanguage` field of the SDK configuration (`AmplyConfig` on iOS and Android, the initialization config in React Native).

## Which format to pass

Pass whatever your localization library gives you. Amply reads all the usual forms and does not care about letter case.

| You pass                         | Amply reads it as      | Notes                                                             |
| -------------------------------- | ---------------------- | ----------------------------------------------------------------- |
| `fr`, `FR`                       | `fr`                   |                                                                   |
| `fr-FR`, `fr_FR`, `fr-fr`        | `fr-FR`                | A region is fine; French text is still found                      |
| `pt-BR`, `pt_BR`                 | `pt-BR`                |                                                                   |
| `zh-Hant`, `zh-TW`, `zh_HK`      | Traditional Chinese    | The region is enough to tell the script                           |
| `zh-Hans`, `zh-CN`, `zh`         | Simplified Chinese     |                                                                   |
| `es-419`, `es-MX`, `es_AR`       | Latin American Spanish |                                                                   |
| `iw`, `in`, `ji`                 | `he`, `id`, `yi`       | Old Java codes are converted                                      |
| `en_US.UTF-8`, `en_US@rg=gbzzzz` | `en-US`                | Extra suffixes are ignored                                        |
| `French`, `Français`, `""`       | not a language         | Ignored; Amply keeps the previous app language and logs a warning |

To check what Amply understood, turn on debug logging. Each call logs a line like:

```
Amply: app language pt-BR (lookup pt-BR → pt)
```

## Which translation the user sees

A sheet or story has a list of languages and a default language. Amply looks for the app language first, then for more general forms of it, and shows the default language if none of them is in the list.

| App language | Amply tries, in order           |
| ------------ | ------------------------------- |
| `pt-BR`      | `pt-BR` → `pt`                  |
| `pt-AO`      | `pt-AO` → `pt-PT` → `pt`        |
| `es-MX`      | `es-MX` → `es-419` → `es`       |
| `fr-CA`      | `fr-CA` → `fr`                  |
| `en-AU`      | `en-AU` → `en-001` → `en`       |
| `zh-Hant-TW` | `zh-Hant-TW` → `zh-Hant`        |
| `zh-Hans-CN` | `zh-Hans-CN` → `zh-Hans` → `zh` |

Two things follow from this:

* **Add the general language when you can.** A sheet with only `pt-BR` shows the default language to a user in Portugal. Add `pt` (or both `pt-BR` and `pt-PT`) to cover every Portuguese speaker. The editor warns you when a variant has no general form.
* **Traditional and Simplified Chinese never replace each other.** A Traditional Chinese reader sees `zh-Hant` text or the default language, never Simplified text.

The editor also warns when a language is only partly translated: untranslated texts show in the default language, so the screen would mix two languages.

## Targeting by app language

The **App language** rule in a campaign's **Who** step includes or excludes users by app language. It uses the same order as above, so:

* `pt` matches every Portuguese user — `pt-BR`, `pt-PT`, `pt-AO`.
* `pt-BR` matches only Brazilian Portuguese.
* `zh-Hant` matches Traditional Chinese, whatever the region.
* `es-419` matches Latin American Spanish, including `es-MX` and `es-AR`.

The rule needs Amply SDK 0.14.0 or newer. On older SDK versions a campaign with this rule is not shown — neither an include nor an exclude matches there.

## Related

* [Targeting an audience](https://docs.amply.tools/user-guide/targeting-an-audience.md)
* [User attributes](https://docs.amply.tools/developer-guide/user-attributes.md)
* [Testing your integration](https://docs.amply.tools/developer-guide/testing-your-integration.md)
