Android的皮棉:如何忽略某个文件丢失翻译警告 [英] Android Lint: how to ignore missing translation warnings in a specific file
问题描述
是否有可能一些字符串翻译,但不是全部,在一个单独的资源文件,而不皮棉抱怨的 MissingTranslation
Is it possible to translate some strings, but not all, in a separate resource file without Lint complaining about MissingTranslation?
例如:我的应用程序的弦都在 RES /价值/ strings.xml中。一个串的是
For example: my app's strings are all in res/values/strings.xml. One of the strings is
<字符串名称=postal_ code>邮政code< /串>
由于邮政code通常被称为拉链code在美国,我想增加其他资源的 RES /值-EN-RUS / strings.xml中与内容:
Since "postal code" is usually called "zip code" in the US, I want to add another resource res/values-en-rUS/strings.xml with contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="postal_code">Zip Code</string>
</resources>
然而,皮棉抱怨在其他字符串价值/ strings.xml中,但不是在值-EN-RUS / strings.xml中
我知道你可以通过指定工具燮preSS的警告:在忽略
价值/ strings.xml中。但由于翻译成另一种语言时,皮棉警告是真正有用的,这是不可取的。
I realize you can suppress the warnings by specifying tools:ignore
in values/strings.xml. But this is undesirable because the Lint warning is actually useful when translating to another language.
相反,是有可能看的时候共进晚餐preSS警告在值-EN-RUS / strings.xml中文件,如,告诉林特不要使用该文件作为标准失踪的翻译?
Instead, is it possible to suppress the warning in the values-en-rUS/strings.xml file, as in, telling Lint not to use that file as criteria when looking for missing translations?
推荐答案
禁用MissingTranslations检查一个很好的方法是添加模块特定的build.gradle文件的选项。
A nice way to disable MissingTranslations check is to add the option in module specific build.gradle file .
android {
lintOptions{
disable 'MissingTranslation'
}
//other build tags
}
如果字符串不在现场的特定字符串的文件present,将采取从一般的strings.xml默认文件中的字符串。
If the strings are not present in locale specific Strings file, it will take the strings from the default file which generally is Strings.xml.
这篇关于Android的皮棉:如何忽略某个文件丢失翻译警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!