3

The locale of Eclipse can be set at start up via eclipse.ini adding this line:

-Duser.language=<locale>

But how can I get the locale in an Eclipse RCP application (plugin)?

flavio.donze
  • 7,432
  • 9
  • 58
  • 91
CIOC
  • 1,385
  • 3
  • 19
  • 48

2 Answers2

4

The same way as in every java application:

Locale.getDefault();

Have a look at "Using a Default Locale":
http://www.oracle.com/technetwork/articles/javase/locale-140624.html?ssSourceSiteId=ocomen#using

There is also the LocaleProvider service, depending on your needs:
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fosgi%2Fservice%2Flocalization%2FLocaleProvider.html

flavio.donze
  • 7,432
  • 9
  • 58
  • 91
0

To load the "-Duser.name=xxx" in a eclipse.ini file within a plugin product. Just use System.getProperty("user.name"). Hope this may help you.

  • It's strange, I started Eclipse in japanese using `-Duser.language=ja` but if I print `System.getProperty("user.language")` I always get `en`, regardless the workbench is in japanese. – CIOC Mar 31 '15 at 16:41