Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic language switching in an Eclipse RCP application

I am working on an Eclipse RCP application with localization. A user should be able to change the language used in the application on the fly. A restart of the application should not take place during this language switch. It should also be possible to switch between languages written from left to right and languages written from right to left.
Is there a (good) way to solve this problem?

like image 650
zizzo Avatar asked Sep 16 '09 09:09

zizzo


2 Answers

According to this thread:

Most of the eclipse libraries load up their language info on widget creation. If you change your locale afterwards you need to restart eclipse to have it take effect.

You could write that kind of dynamic behaviour into your own SWT program, however (when the locale switches, you'd need to call setText(*) on everything :-)

So this is not currently managed dynamically unless you program it yourself...
Other rcp/plugins application like Birt specify the same instructions (i.e. "Restart Eclipse" at the end...)


That said, a slightly different problem was set in this thread:

switch the language setting, restart, and then run in that language

I got it to work by reading bug 222023 and mimicking org.eclipse.ui.internal.ide.actions.OpenWorkspaceAction

I tried it manually:

  • added "-configuration @user.home/.myapp/configuration" to the launcher.ini
  • added "osgi.nl" to the users config.ini residing there and it worked.

Since I can access the config-Location via Platform.getConfigurationLocation() I guess that could be the way.

Note: adding "osgi.nl" to the webstart jnlp works too.

like image 50
VonC Avatar answered Nov 12 '22 22:11

VonC


You would need to call setText on each widget, with the respective text. Since there is no text variable mapping on the widgets, you would have to do that completely manually as well.

like image 41
Alex Avatar answered Nov 12 '22 22:11

Alex