微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android本地化语言环境不起作用,所有区域代码都存在问题

我需要将除瑞士之类的子语言环境添加到我的应用程序中,而不是普通的德语.

我找到的德语资源文件夹的语言环境扩展名为de.所以我的文件夹名为“values-de”.这很好.

然后我添加了“values-de_CH”并继续收到错误“无效的资源目录名称”.

我也试过“values-de_rCH”和“values-de_ch” – 无济于事.

当我将手机设置为德语(瑞士)并从应用程序中打印区域设置时:

String locale = java.util.Locale.getDefault().getdisplayName();
String locale2 = java.util.Locale.getDefault().getLanguage();

if (DEBUG)
    Log.i(this.getClass().getSimpleName(), " ->" + "locale= " + locale
        + "country= " + locale2);

,它也只打印“德”

我也试过“values-en_US”并得到了同样的错误.

当我打印所有可用的语言环境时,我甚至得到这些:

07-30 11:45:38.236: D/asset(2298): locale 32: 'uk_UA'
07-30 11:45:38.236: D/asset(2298): locale 33: 'en_ZA'
07-30 11:45:38.236: D/asset(2298): locale 34: 'en_GB'
07-30 11:45:38.236: D/asset(2298): locale 35: 'et_EE'
07-30 11:45:38.236: D/asset(2298): locale 36: 'ga_IE'
07-30 11:45:38.236: D/asset(2298): locale 37: 'en_IE'
07-30 11:45:38.236: D/asset(2298): locale 38: 'bg_BG'
07-30 11:45:38.236: D/asset(2298): locale 39: 'fi_FI'
07-30 11:45:38.236: D/asset(2298): locale 40: 'sl_SI'
07-30 11:45:38.236: D/asset(2298): locale 41: 'mk_MK'
07-30 11:45:38.236: D/asset(2298): locale 42: 'sk_SK'
07-30 11:45:38.236: D/asset(2298): locale 43: 'no_NO'
07-30 11:45:38.236: D/asset(2298): locale 44: 'ro_RO'
07-30 11:45:38.236: D/asset(2298): locale 45: 'hr_HR'
07-30 11:45:38.236: D/asset(2298): locale 46: 'es_ES'
07-30 11:45:38.236: D/asset(2298): locale 47: 'is_IS'
07-30 11:45:38.236: D/asset(2298): locale 48: 'sr_RS'
07-30 11:45:38.236: D/asset(2298): locale 49: 'en_US'
07-30 11:45:38.236: D/asset(2298): locale 50: 'es_US'
07-30 11:45:38.236: D/asset(2298): locale 51: 'lt_LT'
07-30 11:45:38.236: D/asset(2298): locale 52: 'pt_PT'
07-30 11:45:38.236: D/asset(2298): locale 53: 'en_AU'
07-30 11:45:38.236: D/asset(2298): locale 54: 'hu_HU'
07-30 11:45:38.236: D/asset(2298): locale 55: 'ru_RU'
07-30 11:45:38.236: D/asset(2298): locale 56: 'lv_LV'
07-30 11:45:38.236: D/asset(2298): locale 57: 'kk_KZ'
07-30 11:45:38.236: D/asset(2298): locale 58: 'en_NZ'
07-30 11:45:38.236: D/asset(2298): locale 59: 'nl_BE'
07-30 11:45:38.241: D/asset(2298): locale 60: 'de_DE'
07-30 11:45:38.241: D/asset(2298): locale 61: 'sv_SE'
07-30 11:45:38.241: D/asset(2298): locale 62: 'de_CH'
07-30 11:45:38.241: D/asset(2298): locale 63: 'fr_CH'
07-30 11:45:38.241: D/asset(2298): locale 64: 'da_DK'
07-30 11:45:38.241: D/asset(2298): locale 65: 'nl_NL'
07-30 11:45:38.241: D/asset(2298): locale 66: 'pl_PL'
07-30 11:45:38.241: D/asset(2298): locale 67: 'fr_FR'
07-30 11:45:38.241: D/asset(2298): locale 68: 'el_GR'
07-30 11:45:38.241: D/asset(2298): locale 69: 'ko_KR'
07-30 11:45:38.241: D/asset(2298): locale 70: 'tr_TR'
07-30 11:45:38.241: D/asset(2298): locale 71: 'de_AT'
07-30 11:45:38.241: D/asset(2298): locale 72: 'it_IT'
07-30 11:45:38.241: D/asset(2298): locale 73: 'cs_CZ'

有没有办法让这些地区或有什么特别的我需要做

非常感谢

解决方法:

你需要使用“values-de-rCH”.文件名中不允许使用下划线.

http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐