如何避免Android Lint未翻译的字符串?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (47)

运行Android Lint检查它一直说的问题,说有些翻译缺失..我不想要在整个项目中禁用此项检查,我只想在某些XML文件中禁用它。是否有可能:

"title_widget_updater_service" is not translated in de, en, en-rUS, it

Issue: Checks for incomplete translations where not all strings are translated
Id: MissingTranslation

If an application has more than one locale, then all the strings declared in one language     
should also be translated in all other languages.

By default this detector allows regions of a language to just provide a subset of the 
strings and fall back to the standard language strings. You can require all regions to 
provide a full translation by setting the environment variable 
ANDROID_LINT_COMPLETE_REGIONS.

如何定义这个非本地化字符串的区域

提问于
用户回答回答于

我不知道如何忽略所有的文件,但是你可以使用下面的字符串来实现:

<string name="hello" translatable="false">hello</string>
用户回答回答于

它是字符串文件中命名空间的ignore属性tools,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<resources
  xmlns:tools="http://schemas.android.com/tools"
  tools:ignore="MissingTranslation" >

  <!-- your strings here; no need now for the translatable attribute -->

</resources>

扫码关注云+社区