Getting OS language in java

后端 未结 3 1258
-上瘾入骨i
-上瘾入骨i 2021-01-05 09:45

I\'m running into a kind of problem here.

I\'m French and working on an English version of Windows XP. Therefore, I set the regional options to French, but still hav

3条回答
  •  感情败类
    2021-01-05 10:22

    I have no means to try it out (as I tend to avoid anything made by Microsoft), but take a look at these:

    Java 7 required:

    Locale uiLocale = Locale.getDefault(Locale.Category.DISPLAY);
    

    That's what should be used for getting translations (starting from Java 7), anyway.

    If this was not very helpful, I'd try:

    System.out.println(System.getenv("LC_MESSAGES"));       
    System.out.println(System.getenv("LANG"));
    System.out.println(System.getenv("LANGUAGE"));
    

    However, in this case I would expect some similarities to default Locale...

提交回复
热议问题