开发者

Getting the Locale short code

In Java it is easy enough to get the default Locale, but is there a way to get the short code that you see so often in websites such as lang=en or lang=zh

I need to send to informatio开发者_C百科n to a website but need the short code so the response will be in the correct language.


Locale.getDefault().getLanguage();


Use the Locale.getLanguage() method (API Link)

Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.

ISO-639 is the standard for two-letter language codes. See here for the list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜