开发者

Getting the Locale short code

开发者 https://www.devze.com 2023-01-02 18:45 出处:网络
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

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

精彩评论

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