Eclipse RCP and language selection

Eclipse RCP Clients are usually shipped with language bundles providing the translations of the application’s labels. Depending on the locale (either the system’s default locale or the locale set with the -nl program argument), the client appears with the labels in the defined language. But what about letting the user choose his language, e.g. in a login dialog or during runtime?
Well, simply modifying the default locale using Locale.setDefault() has no effect as the underlaying workbench has been already configured with the startup language. You actually need to restart the client and reset the default locale. Eclipse provides a special exit code IApplication.EXIT_RELAUNCH in order to relaunch a client and use programmatically defined startup parameters. To do so, simply set the system property eclipse.exitdata with the required startup parameters with System.setProperty(). The prefix of the property’s value should be {eclipse.vm}\n, the rest is to be structured like the common .ini file, that is usually used to set the client’s startup configuration. In order to reset the locale, the property’s value needs to contain the -nl program argument set to the language selected by the user. When exiting the Workbench using the IApplication.EXIT_RELAUNCH exit code, the client will then be relaunched using the configuration defined with the eclipse.exitdata property’s value and appear in the requested language.

2 thoughts on “Eclipse RCP and language selection”

  1. Hi,
    I am trying but there is something wrong in my code :
    System.getProperties().setProperty(“eclipse.exitdata”, “\n-nl \n” + locale);
    IApplication.EXIT_RELAUNCH;

    After start I check System.getProperty(“eclipse.commands”) ->all seems to be right.

    When I debug it with param -nl de application starts right.
    Can you help ?
    Thanks Petr

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>