Dynamic Language Switcher for Eclipse RCP Apps

6

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/.

6 Comments

  1. Patrick SchrinerMarch 10, 2008

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

  2. philkMarch 11, 2008

    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é DietisheimMarch 11, 2009

    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. André DietisheimJune 8, 2009

    The eclipse community finally credited the need of being able to switch the language on the fly – while the app’s running.
    There’s a bugzilla entry where you can track the progress of this implementation:
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=75320

  5. Raffaele GambelliJanuary 11, 2011

    I’ve found this useful short article http://www.wickedshell.net/blog/?p=127 but I didn’t yet tried

  6. Raffaele GambelliJanuary 12, 2011

    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