[英]How to get current locale of Eclipse from a plugin?
The locale of Eclipse can be set at start up via eclipse.ini
adding this line: 可以在启动时通过
eclipse.ini
添加以下行来设置Eclipse的语言环境:
-Duser.language=<locale>
But how can I get the locale in an Eclipse RCP application (plugin)? 但是,如何在Eclipse RCP应用程序(插件)中获取语言环境?
The same way as in every java application: 与每个Java应用程序相同的方式:
Locale.getDefault();
Have a look at "Using a Default Locale": 看看“使用默认语言环境”:
http://www.oracle.com/technetwork/articles/javase/locale-140624.html?ssSourceSiteId=ocomen#using http://www.oracle.com/technetwork/articles/javase/locale-140624.html?ssSourceSiteId=ocomen#using
There is also the LocaleProvider service, depending on your needs: 根据您的需求,还有LocaleProvider服务:
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fosgi%2Fservice%2Flocalization%2FLocaleProvider.html http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fosgi%2Fservice%2Flocalization%2FLocaleProvider.html
To load the "-Duser.name=xxx" in a eclipse.ini file within a plugin product. 在插件产品的eclipse.ini文件中加载“ -Duser.name = xxx”。 Just use
System.getProperty("user.name")
. 只需使用
System.getProperty("user.name")
。 Hope this may help you. 希望这对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.