Android 字串資源¶
用於翻譯應用的Android特定文件格式。
The same file format is also used by JetBrains Compose Multiplatform Kotlin Resources.
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>
也參考
Android string resources documentation, JetBrains Compose Multiplatform Kotlin Resources, Android string resources
Weblate configuration for Android resource strings¶
典型的 Weblate 組件組態 |
|
---|---|
檔案遮罩 |
|
單語的基底語言檔 |
|
新翻譯的模板 |
Empty |
檔案格式 |
Android字串資源 |
Weblate configuration for JetBrains Compose Multiplatform Kotlin Resources¶
典型的 Weblate 組件組態 |
|
---|---|
檔案遮罩 |
|
單語的基底語言檔 |
|
新翻譯的模板 |
Empty |
檔案格式 |
Android字串資源 |