gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:38:52 25 4
gpt4 key购买 nike

除了正常的德语之外,我还需要在我的应用中添加瑞士等子语言环境。

我找到的德语资源文件夹的语言环境扩展名是 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);

,它也只打印“de”

我也尝试了“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

关于Android 本地化语言环境不起作用,所有区域代码都有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12194737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com