-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi Everyone,
I am a newbie trying to implement a multilingual application. I created a combobox for user to select language option.
Whenever a language is selected, all labels/buttons on the screen will change the language immediately. The mechanism I am using is as following:
1. Create an EventQueue (e.g. EventQueues.lookup("change", EventQueues.DESKTOP, true);
2. All components defined in zul will be constructed by GenericForwardComposer. Within the doAfterCompose method, an eventlistener listening to EventQueue created at step 1 will be created. Thus, whenever a language is selected, all components will be notified and change labels accordingly.
My problem is : if a containers (e.g. Tabs/Windows) is closed , all its children/subchild/sub-subchild will still be attached to the EventQueue and will never be garbage collected. Is there any way to close all child/subchild component through programs? Or, is there any alternative to create such kind of multilingual application?
Thanks
Ryan :-(
Hi Simon,
Thanks for your reply.
I have tried the standard approach before.
However, with the standard approach, when user choose a different language, I have to refresh the whole page to make it take effect.
The effect I am looking for is : once a user choose a different language, all labels/button will change the language automatically without refreshing the page.
Is there any way to do it ?
Thanks
Ryan :-)
Hi Peter,
Thanks for your suggestion. However, that approach might not be appropiate for my situation since our existing customer has already got used to the effect I mentioned (i.e. implemented in Swing). However, I have figured out how to achieve the effect :
1. Create an interface e.g. ComponentIF with a method reloadLocale
2. Extend existing Zk components with additional attributes (e.g. labelKey, tooltipkey ... for Button, Tab) and implemented ComponentIF.
3. Amend all zuls to point to my version of components (e.g. ?component name="window" extends="window" class="a.b.c.Window"?>)
4. Whenever user selected a different language, call comp.getDesktop() and then iterate over all its components (i.e. desktop.getComponents()) . For each components, if it is an instance of ComponentIF, simply call reloadLocale to force it to reload the labels by using attributes defined in step 2.
Up to this moment, the effect of this approach works quite well.
However, I am still looking for a way to change the css class of the component immediately since difference language may require different appearance (i.e. Can I enforce a component to look at a different css and change its appearance immediately?)
Thanks a lot
Ryan :-)
Asked: 2010-04-14 05:16:55 +0800
Seen: 385 times
Last updated: Apr 23 '10