属性 translatable="false" 到根 <resources> 元素?
Attribute translatable="false" to the root <resources> element?
我在单个 values/fertilizers.xml
文件中有一些化学名称字符串:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>
既然这个文件中的所有这些字符串都不应该被翻译,我可以将单个 translatable="false"
属性添加到根 <resources>
元素中,还是必须为所有的元素添加它?像这样的单个字符串元素:
<string name="grade_dap" translatable="false">Single super phosphate - SSP (00:16:00)</string>
如果你想用它来避免 lint 警告,你可以简单地放置 MissingTranslation 属性来覆盖它们。
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>
参考Android Studio Project Site:
If you have a lot of resources that should not be translated, you can
place them in a file named donottranslate.xml and lint will consider
all of them non-translatable resources.
我在单个 values/fertilizers.xml
文件中有一些化学名称字符串:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>
既然这个文件中的所有这些字符串都不应该被翻译,我可以将单个 translatable="false"
属性添加到根 <resources>
元素中,还是必须为所有的元素添加它?像这样的单个字符串元素:
<string name="grade_dap" translatable="false">Single super phosphate - SSP (00:16:00)</string>
如果你想用它来避免 lint 警告,你可以简单地放置 MissingTranslation 属性来覆盖它们。
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>
参考Android Studio Project Site:
If you have a lot of resources that should not be translated, you can place them in a file named donottranslate.xml and lint will consider all of them non-translatable resources.