| Change 'locale' attribute in TranslationService at Runtime [message #876286] |
Thu, 24 May 2012 06:08  |
Marko Herchet Messages: 10 Registered: May 2012 |
Junior Member |
|
|
There is an attribute
@Inject
@Named(LOCALE)
protected String locale;
in the org.eclipse.e4.core.services.translation.TranslationService class which is used in the translate-implementation of org.eclipse.e4.core.internal.services.BundleTranslationProvider to get the ResourceBundle for the given locale.
I thought that the injection-logic will update the locale-attribute when I do the following:
m_Application.getContext().set(TranslationService.LOCALE, "de");
but nothing happens (breakpoint in translate showed that the value of locale was still 'en' -> the locale.getdefault)
Am I missing smth?
Thanks,
Marko
|
|
|
|
| Re: Change 'locale' attribute in TranslationService at Runtime [message #876362 is a reply to message #876331] |
Thu, 24 May 2012 09:02   |
Marko Herchet Messages: 10 Registered: May 2012 |
Junior Member |
|
|
Thanks for the answer Tom.
I replaced my code with
m_Application.getContext().getParent().set(TranslationService.LOCALE, "de");
and it works the way I want.
Quote:
The problem is that the important code parts (most import ones are the
Renderers) are not reacting on the change of a locale so dynamic switch
the UI won't work as you'd expect it to work 
I think I understand what you mean, but at the time I want to change the locale, the workbench is empty except for MainWindow, MainMenu and the MainToolbar. So it will be no problem as long as there is a way for me to tell the renderers that they have to update/recreate the said 3 elements. Think I've seen smth like MenuManagerRenderer.clean(MUIElement) but I'm not sure if this is what iam looking for.
Some suggests how to archieve this?
Thanks,
Marko
[Updated on: Thu, 24 May 2012 09:03] Report message to a moderator
|
|
|
|
| Re: Change 'locale' attribute in TranslationService at Runtime [message #877399 is a reply to message #876286] |
Sat, 26 May 2012 13:09  |
Marko Herchet Messages: 10 Registered: May 2012 |
Junior Member |
|
|
What I found out, is that some Texts will change automatically after running my code. Tooltips of MainToolbarItems for example seems to be updated on every enablement check. Don't know if this is by design. Labels of Submenus will occur in the right language too, when opened (even if it was opened before the language-change). But iam not sure if the submenu-items are newly created on every menuShow like I usually do it in ContextMenus for my Trees and Tables.
For the other Widgets are not too many, I will just iterate over them after language change and manually change their labels to smth. like MMenuElement.getTranslatedLabel(). Already tried it and it seems to work.
Thanks for your help Tom
|
|
|
Powered by
FUDForum. Page generated in 0.01611 seconds