how to detect operating system language (locale) from java code

后端 未结 4 576
小鲜肉
小鲜肉 2020-11-30 03:09

What is the correct way of knowing operating system language (locale) from java code?

I have tried

Locale.getDefault()
System.getProperties(\"user.l         


        
4条回答
  •  醉酒成梦
    2020-11-30 04:00

    How about using the default locale?

    Locale locale = Locale.getDefault();
    String lang = locale.getDisplayLanguage();
    String country = locale.getDisplayCountry();
    

    This returns me my current language and country as per the Windows systeminfo command. Is this what you're looking for? (If you want the 2-character codes for language/country, you can just use getLanguage() or getCountry()).

提交回复
热议问题