Dynamic language switching in an Eclipse RCP application
Asked Answered
M

2

7

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?

Melan answered 16/9, 2009 at 9:30 Comment(1)
The difficulty is that I do not believe you can call setText(*) on everything automatically...Assist
A
4

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.

Assist answered 16/9, 2009 at 10:10 Comment(1)
Is it possible to get "everything" (to call setText(*) on) automatically?Melan
P
1

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.

Patty answered 27/7, 2012 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.