---
title: "android-strings"
description: "The preset for Android string resources. It reads strings.xml, plurals and string arrays, and R.string and @string usages."
canonical_url: "https://x18n.dev/presets/android-strings"
---
# android-strings

> The preset for Android string resources. It reads strings.xml, plurals and string arrays, and R.string and @string usages.

The `android-strings` preset supports [Android string resources](https://developer.android.com/guide/topics/resources/string-resource).

## Detection

The preset applies when the project has an `AndroidManifest.xml` and a `res/values` folder, unless the root `package.json` depends on React Native, Expo, Capacitor, Cordova or NativeScript, or there is a `pubspec.yaml`: those apps have an `android` folder whose strings are not its messages. A `package.json` kept only for tooling does not stop detection. Otherwise, name it in the config:

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: ['android-strings'],
})
```

## Locale files

`strings*.xml`, `plurals*.xml` and `arrays*.xml` in `res/values*`, in every module. The folder gives the locale:

| Folder             | Locale            |
| ------------------ | ----------------- |
| `values`           | The source locale |
| `values-fr`        | `fr`              |
| `values-zh-rCN`    | `zh-CN`           |
| `values-b+sr+Latn` | `sr-Latn`         |

Other folders, such as `values-night` and `values-land`, are not locales. A new locale gets the folder Android expects.

In a file, `<string>` is a key, `<plurals>` is one key per quantity (`items.one`), and `<string-array>` is one key per item (`days.0`). Deleting an item before the end empties it, so later items keep their index. `translatable="false"` is not a message, and x18n does not write to it. A comment right above an entry is its description for translators. x18n reads and writes Android's escapes (`\\n`, `\\'`, `\\"`, a leading `\\@`), keeps inline markup such as `<b>`, and keeps CDATA.

## Supported syntax

In Kotlin and Java, `R.string.key`, `R.plurals.key` and `R.array.key`. In XML, `@string/key`, `@plurals/key` and `@array/key`. `android.R.string.ok` and `@android:string/ok` are the framework's, not usages. A `name` with a dot is `R.string.a_b` in code, which x18n does not map to `a.b`.

## Placeholders

`%s`, `%d`, `%1$s`.


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
