这发生在我们在印度尼西亚的所有设备上。
国家代码是正确的,显示语言和 ISO3 似乎也是正确的:
Locale.getDefault().getISO3Country() // "IDN"
Locale.getDefault().getDisplayCountry() // "Indonesia"
Locale.getDefault().getCountry() // "ID"
Locale.getDefault().getISO3Language() // "ind"
Locale.getDefault().getDisplayLanguage() // "Bahasa Indonesia"
但是正常的语言代码是错误的,应该是“id”而不是“in”。然后 android 也生成了错误的 language_COUNTRY 标识符,应该是“id_ID”而不是“in_ID”:
Locale.getDefault().getLanguage() // "in"
Locale.getDefault().toString() // "in_ID"
这是一个已知问题吗?我们能做些什么?
氰化物建议只覆盖语言环境,但对于真正需要使用“in”而不是“id”的设备来说,这对他们来说是错误的吗?
最佳答案
好吧,找出它发生的原因,请参阅 Android Locale Constructor Reference :
ISO 639 is not a stable standard; some of the language codes it defines (specifically "iw", "ji", and "in") have changed. This constructor accepts both the old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other API on Locale will return only the OLD codes.
所以我们无能为力,在应用程序内部使用“in”表示字符串等,并在与后端服务器等外部实体通信时将其转换为“id”(或将 in 视为 id)。
关于Android 为印度尼西亚生成错误的语言代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44245959/