Error: "***" is not translated in "zh" (Chinese) [MissingTranslation]

场景描述:

在用Android Studio生成带签名的apk时报的这个错误。


原因分析:

If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages. 
Android Studio里要求每个string在每个语言环境里的xml资源文件里都要翻译。


解决方案:


1.把所有字符串在每种语言下都翻译(这是推荐的做法)。

2.对于不想翻译的字符串,添加translatable=”false”属性
<string name="app_name" translatable="false">sample</string>


3.Settings设置
File->Settings->Editor->Inspections右边列表里有Incomplete translation或者直接在File->Settings的搜索框里搜索MissingTranslation关键字,然后选中Incomplete translation不右边的Severity改为Warning或者更低级别。 这个方法我验证没通过,不过也写在这儿吧,看着很有道理的方法


补充
关于这部分的知识,可以参考下面的一段话。

Incomplete translation 


If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages. 
If the string should not be translated, you can add the attribute translatable=”false” on the element, or you can define all your non-translatable strings in a resource file called donottranslate.xml. Or, you can ignore the issue with a tools:ignore=”MissingTranslation” attribute. 


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. 


You can tell lint (and other tools) which language is the default language in your res/values/ folder by specifying tools:locale=”languageCode” for the root element in your resource file. (The tools prefix refers to the namespace declaration http://schemas.android.com/tools.)


参考的文章http://www.voidcn.com/blog/bingospunky/article/p-4946580.html


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值