eclipse Lint:如何忽略“<key> 未翻译成<language>”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11443996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Lint: How to ignore "<key> is not translated in <language>" errors?
提问by Nicolas Raoul
I can't compile/debug our Android app, because the localization files are not perfect yet.
我无法编译/调试我们的 Android 应用程序,因为本地化文件还不完善。
My IDE's validation tool Lintcreate errors saying:
我的 IDE 验证工具Lint创建错误说:
newCardsOrderVals is not translated in ar, bg, ca, cs
newCardsOrderVals 未翻译成 ar、bg、ca、cs
Compiling/installing/running with Ant works fine, but I would like to use my IDE to ease debugging.
使用 Ant 编译/安装/运行工作正常,但我想使用我的 IDE 来简化调试。
Is there a way to turn off this particular check, or ideally make it a warning rather than an error?
有没有办法关闭此特定检查,或者理想情况下将其设为警告而不是错误?
I understand that before release we will really need to get localisation files right, but for the time being it is not a priority as the screens themselves are being modified very frequently.
我知道在发布之前我们确实需要正确地获取本地化文件,但目前这不是优先事项,因为屏幕本身经常被修改。
回答by Nicolas Raoul
Android Studio:
安卓工作室:
- "File" > "Settings" and type "MissingTranslation" into the search box
- “文件”>“设置”并在搜索框中输入“MissingTranslation”
Eclipse:
蚀:
- Windows/Linux: In "Window" > "Preferences" > "Android" > "Lint Error Checking"
- Mac: "Eclipse" > "Preferences" > "Android" > "Lint Error Checking"
- Windows/Linux:在“窗口”>“首选项”>“Android”>“Lint 错误检查”中
- Mac:“Eclipse”>“首选项”>“Android”>“Lint 错误检查”
Find the MissingTranslation
line, and set it to Warning
as seen below:
找到该MissingTranslation
行,并将其设置Warning
为如下所示:
回答by efor18
You can set the attribute translatable="false" on the definition like this:
您可以在定义上设置属性 translatable="false" ,如下所示:
<string name="account_setup_imap" translatable="false">IMAP</string>
For more information: http://tools.android.com/recent/non-translatablestrings
有关更多信息:http: //tools.android.com/recent/non-translatablestrings
回答by Janusz
To ignore this in a gradle build add this to the android section of your build file:
要在 gradle 构建中忽略这一点,请将其添加到构建文件的 android 部分:
lintOptions {
disable 'MissingTranslation'
}
回答by Tom Bollwitt
This will cause Lint to ignore the missing translation error for ALL strings in the file, yet other string resource files can be verified if needed.
这将导致 Lint 忽略文件中所有字符串的缺失翻译错误,但如果需要,可以验证其他字符串资源文件。
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
回答by Eduko
If you want to turn off the warnings about the specific strings, you can use the following:
如果要关闭有关特定字符串的警告,可以使用以下命令:
strings.xml
字符串.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--suppress MissingTranslation -->
<string name="some_string">ignore my translation</string>
...
</resources>
If you want to warn on specific strings instead of an error, you will need to build a custom Lint rule to adjust the severity status for a specific thing.
如果要针对特定字符串发出警告而不是错误,则需要构建自定义 Lint 规则来调整特定事物的严重性状态。
回答by Brais Gabin
Insert in the lint.xml
file this:
在lint.xml
文件中插入:
<?xml version="1.0" encoding="UTF-8"?>
<lint>
...
<issue
id="MissingTranslation"
severity="ignore" />
</lint>
For more details: Suppressing Lint Warnings.
有关更多详细信息:抑制 Lint 警告。
回答by Purvik Rana
add the lines in your /res/values.xml file in resource root tab like this:
在资源根选项卡中添加 /res/values.xml 文件中的行,如下所示:
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:locale="en" tools:ignore="MissingTranslation">
tools:locale set the local language to English, no need of language translation later on that for all resource strings and tools:ignore let Lint to isnore the missing translations of the resource string values.
tools:locale 将本地语言设置为英语,以后不需要对所有资源字符串和工具进行语言翻译:忽略让 Lint 不再需要资源字符串值的缺失翻译。
回答by chzahid
Add following to your gradle file in android section
将以下内容添加到 android 部分的 gradle 文件中
lintOptions {
disable 'MissingTranslation'
}
回答by Jinbom Heo
In addition,
此外,
Not project dependent properities, Eclipse Preferences.
In Mac, Eclipse > Preferences
不是项目相关属性,Eclipse 首选项。
在 Mac 中,Eclipse > 首选项
回答by kip2
Another approach is to indicate the languages you intend to support and filter out the rest using the 'resConfigs' option with Gradle.
另一种方法是使用 Gradle 的“resConfigs”选项来指示您打算支持的语言并过滤掉其余的语言。
Check out this other answerfor details
查看此其他答案以了解详细信息
This is better, I think, because you don't have to completely ignore legitimate translation mistakes for languages you actually want to support
我认为这更好,因为您不必完全忽略您真正想要支持的语言的合法翻译错误