Search code examples
javaeclipse-plugininternationalizationeclipse-rcplocale

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:

-Duser.language=<locale>

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


Solution

  • 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