Android 字串資源¶
用於翻譯應用的Android特定檔案格式。
提示
A very similar formats are Compose Multiplatform 資源 and Mobile Kotlin 資源.
Android string resources are monolingual, the 單語言基底語言檔案 is
stored in a different location from the other files -- res/values/strings.xml.
Weblate does following escaping of strings:
If a strings is valid XML, it is inserted as XML to translation.
?and@are escaped with a\\at the beginning of the string to avoid interpreting them as style or resource references.In case string contains multiple spaces, it is quoted with double quotes (
").Newlines are escaped as
\\n, but the actual newline is kept for readability as well.
備註
目前不支援Android的 string-array 架構。為瞭解決這個問題,可以將字串陣列分開:
<string-array name="several_strings">
<item>First string</item>
<item>Second string</item>
</string-array>
變為:
<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
提示
To avoid translating some strings, these can be marked as non-translatable. This can be especially useful for string references:
<string name="foobar" translatable="false">@string/foo</string>
也參考
副檔名 |
|
|---|---|
語言能力 ⓘ |
單語言 |
支援複數 ⓘ |
|
支援描述 ⓘ |
|
支援解釋 ⓘ |
|
Supports context ⓘ |
|
Supports location ⓘ |
|
Supports flags ⓘ |
|
API 識別碼 |
|
支援唯讀字串 ⓘ |
|
Check flags added by this format ⓘ |
Weblate 配置¶
典型的 Weblate 組件配置 |
|
|---|---|
檔案遮罩 |
|
單語言基底語言檔案 |
|
新翻譯的範本 |
空白 |
檔案格式 |
Android 字串資源 |