Tag Archives: language selection

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.