在使用 android 的国际化时,会经常遇到这种错误
“hello world” is translated here but not found in default locale
这是 Lint 检查的问题,解决的办法有很多,取一种即可:
- 1.app/build.gradle 下添加如下代码:
android {
...
lintOptions {
disable 'MissingTranslation'
}
...
}
- 2.在你编写的出错的 resource.xml 文件下添加:
<?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>
- 3.直接在报错的语句下面改为:
<string name="hello" translatable="false">hello</string>
- 4.在设置中取消
"Window" > "Preferences" > "Android" > "Lint Error Checking"
取消勾选