Hello,
while the other suggestions are good and will work i have another that
works without any coding or patches with XForms itself. we've used this
approach successfully in our projects.
it works like this:
- you write a xml-file with all the keys you want as xml element names
and putting in the translation of your default language as value e.g.
<mydict>
<foo>whatever foo translates to in your language</foo>
...
</mydict>
you create a similar file with the same structure for every language,
naming them lang_en.xml, lang_it.xml, lang.de ... then in your xforms
you load these files as instance-data which makes them available to
label binds e.g.
...
<xf:label ref="instance('lang')/foo"/>
...
the instance tag might look like this:
<xf:instance src="lang.xml" id="lang"/>
but how can you switch between languages now? well, XForms comes to your
rescue and we can use it for 'copying' instances around.
to switch the language you'll need to write one submission for every
language such as
<xf:submission id="load-lang" ref="instance('lang')" replace="instance"
method="get" action="lang_en.xml"/>
if you now trigger the submission by a language selection button or
select1, the current instance (whatever language may be loaded) will be
replaced with the one referenced by the 'action' attribute.
if you want to persist the users choice so its available next time the
form is started you can do an additional submit (method put) doing a
normal save to file 'lang.xml' thus overwriting its original content.
this appraoch requires two things:
1. you'll a 'lang.xml' which redundantly mirrors one of your lang_xx.xml
files and is deployed along with them. this is the default language
shown when the form comes up. when one of the relevant submissions fire,
this files' content is replace by the wanted language.
2. the number of languages must be known beforehand and you'll have to
write one submission for every language you want to support. but i
assume this should be the case anyway - how else should you have a
translation at hand?
btw, as William mentioned it's convenient to have the i18n as instance
data cause this give you a chance to also internationalize the labels of
select/select1 lists.
Joern
Mihnea Galeteanu wrote:
Hi,
I was wondering how would I go about developing an internationalized
xform that used resource bundle to localize labels for example.
Thanks,
Mihnea (Mike) Galeteanu
Software Developer
FreeBalance - global leaders in e-Government software
Tel: +1 613 236 5150 ext 339
Fax: +1 613 236 7785
mgaleteanu-Nc24Izxk5nwdH0auuBZGHA@xxxxxxxxxxxxxxxx
FreeBalance proudly welcomes Influatec to the FreeBalance family.
You can find out more at www.FreeBalance.com.
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|