在java中获取操作系统语言
我在这里遇到了一种问题.
I'm running into a kind of problem here.
我是法国人,正在使用英文版的 Windows XP.因此,我将区域选项设置为法语,但仍然有英语 UI.
I'm French and working on an English version of Windows XP. Therefore, I set the regional options to French, but still have an English language UI.
我正在开发一个小型 Java SE 应用程序,并决定使用资源包将其国际化.
I'm working on a small Java SE application, and decided to internationalize it using resources bundle.
为了显示正确的语言,我用这个函数创建了包:
To display the proper language, I create the bundle with this function :
private static ResourceBundle bundle = ResourceBundle
.getBundle("locale.Strings", Locale.getDefault());
但是 Locale.getDefault() 函数返回区域设置(意思是:法语)而不是系统 UI 语言.结果,我的 UI 在英语环境中默认为法语.好吧,这并不是我所期望的......
But the Locale.getDefault() function returns the regional settings (meaning : French) and not the system UI language. As a result, my UI defaults to French, in an English environment. And well, that's not really what I expected...
有谁知道恢复系统 UI 语言的独立于平台的方法?提前致谢!
Does anyone knows of a platform-independent way to recover the system UI language ? Thanks in advance !
将 Local 固定为 Locale,谢谢.
Edit : fixed Local to Locale, thanks.
推荐答案
这是 Windows 中的错误配置.Locale#getDefault()
返回系统区域设置,而不是日期/时间格式化区域或位置.
This is a misconfiguration in Windows. The Locale#getDefault()
returns the system locale, not the date/time formatting region or location.
在下面的 Windows XP 特定屏幕截图中,您可以将 Regional Options 和 Language 设置为法语或您喜欢的任何内容.高级菜单中的下拉菜单实际上设置了系统区域设置,在您的情况下应该设置为英语.
In the below Windows XP specific screenshot, you could just set the Regional Options and Language to French or whatever you like. The dropdown in the Advanced menu actually sets the system locale and should in your case be set to English.
诚然,这在 Windows XP 中解释得不好,Windows 7 做得更好:
Admittedly, this is in Windows XP poorly explained, Windows 7 does it somewhat better:
相关文章