android - 避免 Android Lint 提示未翻译的字符串

标签 android android-resources android-lint

是否可以指定 value-* 目录中的文件中的字符串故意不翻译成其他语言?我有一堆所有语言通用的字符串,不需要翻译,所以我在 values 目录中创建了一个 unlocalized-strings.xml 文件。运行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.

如何定义这个区域未本地化字符串?

最佳答案

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

<?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>

关于android - 避免 Android Lint 提示未翻译的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12590739/

相关文章:

java - 如何动态多次注入(inject)LinearLayout(Android)?

java - 在没有上下文的情况下访问资源

android - 如何在代码中引用 Android 库的 strings.xml 中的字符串?

安卓 Lint 警告 : "Redundant array creation for calling varargs method"

android - 解释 ClickableViewAccessibility

java - 检查 Map 中是否存在键后,拆箱可能会产生空指针异常

java - 获取滑动菜单抽屉状态

android - 单元测试 proto3 生成的对象与验证

android - 日历中 rrule 的日期格式

java - 有没有类似Android的资源系统的更小规模的?