September 26, 2007

Switching between languages at runtime

One of the requirements we have in our project is to support switching between different languages at runtime. To make this work in the RCP runtime, we decided to close the workbench window and open a new one when the language changes. This works quite well, especially since we have put all state data of the gui in separate models.
Another thing was how to handle data lazily loaded by the platform. For example, a view tab may be visible before the view is actually instanciated. The platform then uses the data (name) given in the extension definition of the view. But this is static, so it won't change if the language changes. We solved this by providing what we call ViewLocalizations via a custom extension point. The ViewLocalization resides in the same bundle as the view it belongs to and knows how to translate the view name. Our Presentation then uses the view localization to determine the right name for the view. Of course, a bundle should not be activated only because one of its ViewLocalizations is needed. Therefore, we put all the ViewLocalizations of a bundle in a separate package which we excluded from the lazyStart-mechanism.
This solution works quite well, but generates a considerable overhead. Especially since beside views, also perspectives, actions, etc. have to be handled this way. So if you have any ideas for improvements, please let me know.

About Me

codes for a living and also in his freetime, probably for lack of a real hobby. ;-)