PDA

View Full Version : Dynamic Button Text for Multilingual App


ianpullinger
07-18-2005, 01:08 AM
I am looking for the best way of setting the text attribute of components at runtime. I am building an application that will allow the user to select a language (both at startup and runtime), which will dynamically load a dataset over http that includes the XML file containing the necessary GUI labels. i.e. for an 'en' language ...

<?xml version="1.0" encoding="UTF-8"?>
<LabelData>
<lang>EN</lang>
<tab1>News</tab1>
<tab2>Sport</tab2>
</LabelData>

I am having trouble easily setting the text attribute of components. Ideally, the following code fragments would work.

<button text="dsLabels:/LabelData/tab1/text()" />

OR ...

<button>
<text datapath="dsLabels:/LabelData/tab1/text()" />
</button>

However, both of these example just display the text in the parent view over the top of the button, and NOT actually in the button! As there could potentially be hundreds of GUI components that will require updating, I am looking for an efficient method and one that will not bloat the application with unneccessary code.

Any help would be appreciated,
Ian

userfriendly
07-18-2005, 09:18 PM
the first version (<button text="...) should work (though i think you have to use $path{} in it) - an alternative is <button datapath="...

don't know what your problems are, i do it exactly that way in my multilingual user interface (yes, my text displays _on_ the buttons)... and it works flawlessly.

ianpullinger
07-18-2005, 09:28 PM
Thanks for that userfriendly ... it seems the only combination I did not try was the one that works !!!

The following works fine:

<button datapath="dsLabels:/LabelData/tab1/text()" />

Cheers, Ian