3

除了普通的德语语言之外,我还需要在我的应用程序中添加像瑞士这样的子语言环境。

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

有没有办法拥有这些地区或者我需要做些什么特别的事情?

非常感谢

4

1 回答 1

6

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

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

于 2012-08-30T11:09:34.033 回答