Why does Locale.getDefault().getLanguage() in Android return the display name instead of the language code?

前端 未结 4 1147
青春惊慌失措
青春惊慌失措 2021-02-14 02:56

According to the Java reference, Locale.getLanguage() is supposed to return the 2-letters lowercase ISO code of the language (e.g. en), while get

4条回答
  •  耶瑟儿~
    2021-02-14 03:20

    Android is returning the readable names instead of the codes.

    Locale.getDefault() has the string. So if you call any prints or Logs on that it'll work... meaning Locale.getDefault().toString() has your locale code.

提交回复
热议问题