问题
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?
回答1:
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 usersconfig.ini
residing there and it worked.Since I can access the
config-Location
viaPlatform.getConfigurationLocation()
I guess that could be the way.
Note: adding "osgi.nl
" to the webstart jnlp works too.
回答2:
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.
来源:https://stackoverflow.com/questions/1431949/dynamic-language-switching-in-an-eclipse-rcp-application