<a id="aresource"></a>

# Android 文字列リソース

<a id="index-0"></a>

アプリケーションを翻訳するための Android 固有のファイル形式。

#### HINT
よく似た形式として、[Compose Multiplatform のリソース](https://docs.weblate.org/ja/latest/formats/compose-multiplatform-resources.md) と [モバイル Kotlin リソース](https://docs.weblate.org/ja/latest/formats/moko-resources.md) があります。

Android の文字列リソースはモノリンガルです。[モノリンガル用の、基礎となる言語ファイル](https://docs.weblate.org/ja/latest/admin/projects.md#component-template) は他のファイルとは異なる場所に保存されます -- `res/values/strings.xml` 。

Weblate がエスケープする文字列:

* 文字列が有効な XML である場合、文字列は XML として翻訳に挿入されます。
* 文字列の先頭にある `?` と `@` は、スタイルやリソースへの参照として解釈されないように `\\` を付けてエスケープされます。
* 文字列に複数のスペースが含まれている場合、二重引用符（`"`）で囲まれます。
* 改行は `\\n` としてエスケープされますが、読みやすくするために実際の改行も維持されます。

#### NOTE
現在、Android の string-array 構造体には対応していません。これを回避して、文字列配列を分解する例:

```xml
<string-array name="several_strings">
    <item>First string</item>
    <item>Second string</item>
</string-array>
```

分割して書き換える方法:

```xml
<string-array name="several_strings">
    <item>@string/several_strings_0</item>
    <item>@string/several_strings_1</item>
</string-array>
<string name="several_strings_0">First string</string>
<string name="several_strings_1">Second string</string>
```

string 要素を指す string-array は、別のファイルに格納することが必要であり、翻訳には使用できません。

既存の strings.xml ファイルと翻訳を事前に処理するのに便利なスクリプト:　[https://gist.github.com/paour/11291062](https://gist.github.com/paour/11291062)

#### HINT
文字列の翻訳を回避するため、文字列にマークを付けて翻訳禁止に設定できます。とても便利な文字列が翻訳禁止かどうかを確認するための設定方法:

```xml
<string name="foobar" translatable="false">@string/foo</string>
```

#### SEE ALSO
* [Android 文字列リソースのドキュメント](https://developer.android.com/guide/topics/resources/string-resource)
* [Compose Multiplatform のリソース](https://docs.weblate.org/ja/latest/formats/compose-multiplatform-resources.md)
* [モバイル Kotlin リソース](https://docs.weblate.org/ja/latest/formats/moko-resources.md)
* [Android string resources](https://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/android.html)

<!-- AUTOGENERATED START: format-features aresource -->
<!-- This section is automatically generated by `./manage.py list_format_features`. Do not edit manually. -->

#### 対応機能

| File extensions                                                                                      | `.xml`                                                                          |
|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| Linguality [ⓘ](https://docs.weblate.org/ja/latest/formats.md#bimono)                                   | Monolingual                                                                     |
| Supports plural [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-plurals)                      | `Yes`                                                                           |
| Supports descriptions [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-description)            | `Yes`                                                                           |
| Supports explanation [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-explanation)             | `No`                                                                            |
| Supports context [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-context)                     | `No`                                                                            |
| Supports location [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-location)                   | `No`                                                                            |
| Supports flags [ⓘ](https://docs.weblate.org/ja/latest/formats.md#format-flags)                         | `Yes`                                                                           |
| API identifier                                                                                       | `aresource`                                                                     |
| Supports read-only strings [ⓘ](https://docs.weblate.org/ja/latest/formats.md#read-only-strings)        | `Yes`                                                                           |
| Supports removing obsolete strings [ⓘ](https://docs.weblate.org/ja/latest/formats.md#obsolete-strings) | `No`                                                                            |
| Check flags added by this format [ⓘ](https://docs.weblate.org/ja/latest/admin/checks.md#custom-checks)      | [Java 形式](https://docs.weblate.org/ja/latest/user/checks.md#check-java-printf-format) |
<!-- AUTOGENERATED END: format-features aresource -->

## Weblate の設定

|                      | 典型的な Weblate [コンポーネント構成](https://docs.weblate.org/ja/latest/admin/projects.md#component)   |
|----------------------|-----------------------------------------------------------------------------------|
| ファイル マスク             | `res/values-*/strings.xml`                                                        |
| モノリンガル用の、基礎となる言語ファイル | `res/values/strings.xml`                                                          |
| 新しい翻訳のテンプレート         | Empty（空）                                                                          |
| ファイル形式               | Android 文字列リソース                                                                   |
