Re: i18n with swixml
Frank Meißner <[email protected]>
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
Kovács Lajos wrote: > Hello everybody! > > I started to use the swixml and it seems to be a very powerfull tool. > Congratulation! > > I have a question about the internationalization (i18n) technique with > swixml. I see that there are two custom tags, "bundle" and "locale" for > this reason. Unfortunately not woking as I expected. > > I want to change online the strings on the GUI according to the selected > Locale (ex. selecting from a combobox). I made a resource bundle and I put > it as an attribute for the root tag. For the other tags (ex. button) for > the text I use only the keys from the bundle's property files. This is > working well, the buttons shows the local texts. > > 1) But how can I change it after the parsing? I can made in the code again > the resource bundle and set for all the texts but this is wrong. Exist a > way to reach or change the resource bundle made by the parser and only make > a refresh for the GUI. Hello, IMHO the only option you have is to render the GUI again. I did not do this in practice, though. The way swixml handles the locale issue is to respect the locale coming from the system at program startup. This is fine and IMHO fits the normal usage of a program. Sure it is a cool thing to change the locale in your program and everything (dates, numbers, scrollbars, ...) will suddenly change. But this is not a customer cares for... Correct me if I'm wrong... > > 2) The components doesn't inherit the Local setting from the root tag, so > all the texts will be arabic, for example, but the scrollpane doesn't shows > the scroll bar in the left side. For this need to specially add a Locale > attribute to the scrollbar. But in this way, you need to specify the Local > many places in the XML file, instead of one place the root tag. > It would be a good approach to use for all the tags the main (root tag's) > Local, if no one is specified. There is no inheritance in respect to the locale. The way I would solve this requires adding a property change listener to your root component. This has to be a subclass of JComponent (which it usually is) so you have the method addPropertyChangeSupport(String, PropertyChangeListener) This method you call with the string "Locale" and a PropertyChangeListener which does in its propertyChange method the following: Foreach component of rootComponent.getComponents() set the locale according to the one the user selected. If the component you set the locale for happens to be a container as well, iterate through its subcomponents as well. > > Has anybody some ideea, how can I resolve this problems? Hope this gave you some ideas ;) Frank > > Best Regards, > Lajos > > > > > _______________________________________________ > Forum mailing list > [email protected] > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com > -- AuthentiDate International AG GroÃenbaumer Weg 6 40472 Düsseldorf / Germany Phone : +49(0)211 43 69 89-0 FAX : +49(0)211 43 69 89-19 IT Sicherheit in Chemie- und Pharma-Unternehmen 25. Nov. 2003, Düsseldorf Erfahren Sie mehr unter: www.authentidate.de