Dynamic Language Switcher for Eclipse RCP Apps

People often ask me how to dynamically change the language in an Eclipe RCP application. I tried it out myselft and have to admit that it is not as easy as I would have expected. The problem is that PlatformUI.getWorkbench().restart() does not allow to set (or change) any new startup parameters, like -nl de. I have already filed a feature request for that (see 222023). The only workaround I found so far is to modify the product’s .ini file of the deployed RCP based product manually. Unfortunately I did not find a solution that works during development using launchers. I have implemented the dynamic language switcher in the plug-in com.siemens.ct.mp3m.language, see the project home page of the MP3 Manager demo (see http://max-server.myftp.org/trac/mp3m). Below is a screenshot showing the language menu:

language menu

A nice set of free flag icons you can find at
http://www.famfamfam.com/lab/icons/flags/.

This Post Has 6 Comments

  1. Patrick Schriner

    Azureus has had dynamic language switching for quite some time, though I’ve not looked into their code yet.

  2. philk

    Well Eclipse should support dynamic language switching, thats true. I have experimented with an approach using reflection on all the loaded NLS classes and simply reloading them. However the UI needs to reflect those changes to so ViewPart and EditorPart should in their base implementation introduce a new Interface like ILocaleSwitchListener that will be notified about changes in Locale. It should then re-label all controls it created (as well as table column headers etc.) One could also think about implementing such into or on top-of SWT. So the user of SWT would not have to care about it.

  3. André Dietisheim

    thanks for divulging your approach! Spares research and development time!
    As far as I know, Azureus is not RCP based, it’s a custom built framework using plain SWT. The sister project at the swiss rail was trying to change the language on-the-fly, too but failed on the update needed on the UI elements (Actions).

  4. Raffaele Gambelli

    Hi Kai hi all, I read bug 222023 and 75320 but I didn’t find a way to relaunch an rcp with a different Locale
    The article that I post in previous comment didn’t helped me…so I would like to know if finally you found a solution, thanks and best regards

Leave a Reply

I accept the Privacy Policy