Adventures with internationalization

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Adventures with internationalization

Tambet Matiisen
Hi everyone!

I started implementing internationalization in our XForms-based
application and most obvious starting point was Orbeon's i18n how-to:
http://wiki.orbeon.com/forms/how-to/i18n

This requires writing all labels of controls in style similar to this:
<xforms:label ref="$resources/registration/first-name"/>

Orbeon's example was fine, but variables are not standard XForms feature
and I wanted to use pure XForms markup as much as possible. Taking ideas
from Wikibooks (see
http://en.wikibooks.org/wiki/XForms/Dynamic_Labels_in_Local_language) I
modified Orbeon's example to use only standard XForms features (see
attached i18n-xforms.zip). This requires writing labels like this:
<xforms:label
ref="instance('all-resources')/resources[@xml:lang=instance('language')]/registration/first-name"/>

As you see, the XPath expression is much longer. This looks ugly and has
possible performance drawbacks. I noticed that I could shorten the
XPaths noticeably, if I put all languages into separate files. Taking
also inpiration from XForms Essentials book
(http://xformsinstitute.com/essentials/browse/book.php#ch10-8-fm2xml) I
made another round of modifications (see attached i18n-pepe.zip) and now
labels started looking rather acceptable:
<xforms:label ref="instance('resources')/registration/first-name"/>

If you look into source code, then you could see that I used one
non-standard XForms feature - AVT in xforms:submission's action
attribute. I don't see this as a major problem, because firstly Chiba
also supports this and secondly if Orbeon supported it, I would have
used resource element under submission. This is XForms 1.1 feature,
which allows you generate submission URL dynamically from instance data.
Orbeon mentions that it wouldn't be hard to implement it, but currently
it is not (see
http://wiki.orbeon.com/forms/doc/developer-guide/orbeon-forms-xforms-compliance-matrix).

Finally I decided, that I don't need ability to switch languages on fly.
The language is fixed in user's session and if user changes it, the page
is anyway reloaded. So I removed everything that was related to dynamic
language change, which made the form even simpler (see attached
i18n-simple.zip). Notice that language is currently fixed in resource
instance's src attribute, but you could easily overcome this by:
1) modifying the form on-fly before giving it to XForms engine (we use
XSL stylesheets for that),
2) specifying in instance's src attribute an URL to a script, that
returns correct resource file based on language in user's session. You
might need to set up cookie forwarding for this to work (I've done that).

Now the thing why I wrote this e-mail. I still don't like the solution,
because simple form is now split into several files - form itself and
resource file for each language. While this has good points (you can add
new languages without modifying the original form), it makes deployment
and distribution of forms much more hassle than it used to be. My dream
would be that everything is in one file, simple and elegant (see
attached i18n-deam.zip):
1) current language is indicated by xml:lang attribute of xhtml:html tag
(you could use AVT in there in Orbeon):
<xhtml:html xml:lang="en">
2) all labels have xml:lang attribute. Only those labels are shown,
whose xml:lang matches that of xhtml:html element.
<xforms:label xml:lang="en">First name</xforms:label>
<xforms:label xml:lang="fr">Prénom</xforms:label>

I think that I could implement that with pre-processing stylesheet, if
changing language dynamically is not allowed.

What is your take on this? Are there any drawbacks with some of the
implementations, that I might have not thought of? Do you think my dream
of simple internationalization of XForms will ever get implemented in
Orbeon or in standard?

Thanks for your attention,
   Tambet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

i18n-dream.zip (1K) Download Attachment
i18n-orbeon.zip (2K) Download Attachment
i18n-pepe.zip (3K) Download Attachment
i18n-simple.zip (2K) Download Attachment
i18n-xforms.zip (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Adventures with internationalization

Erik Bruchez
Administrator
Tambet,

Thanks for all the analysis! The only thing that would be missing in
Orbeon to do your dream version of support for xml:lang on labels,
etc. It would be nice to support this, although at this point it is
not a priority as we are reasonably happy with the solution we have in
Form Runner but if somebody is willing to implement it… ;)

It is a good and elegant solution in some cases. As drawbacks, I see:

* mixing resources with the form might make it harder for somebody
external to localize
* you cannot reuse a given resource for multiple labels (for common
text like say a "Close" label)
* you cannot dynamically load resources (not a problem if you don't need it)

-Erik

On Thu, Nov 4, 2010 at 8:57 AM, Tambet Matiisen
<[hidden email]> wrote:

> Hi everyone!
>
> I started implementing internationalization in our XForms-based application
> and most obvious starting point was Orbeon's i18n how-to:
> http://wiki.orbeon.com/forms/how-to/i18n
>
> This requires writing all labels of controls in style similar to this:
> <xforms:label ref="$resources/registration/first-name"/>
>
> Orbeon's example was fine, but variables are not standard XForms feature and
> I wanted to use pure XForms markup as much as possible. Taking ideas from
> Wikibooks (see
> http://en.wikibooks.org/wiki/XForms/Dynamic_Labels_in_Local_language) I
> modified Orbeon's example to use only standard XForms features (see attached
> i18n-xforms.zip). This requires writing labels like this:
> <xforms:label
> ref="instance('all-resources')/resources[@xml:lang=instance('language')]/registration/first-name"/>
>
> As you see, the XPath expression is much longer. This looks ugly and has
> possible performance drawbacks. I noticed that I could shorten the XPaths
> noticeably, if I put all languages into separate files. Taking also
> inpiration from XForms Essentials book
> (http://xformsinstitute.com/essentials/browse/book.php#ch10-8-fm2xml) I made
> another round of modifications (see attached i18n-pepe.zip) and now labels
> started looking rather acceptable:
> <xforms:label ref="instance('resources')/registration/first-name"/>
>
> If you look into source code, then you could see that I used one
> non-standard XForms feature - AVT in xforms:submission's action attribute. I
> don't see this as a major problem, because firstly Chiba also supports this
> and secondly if Orbeon supported it, I would have used resource element
> under submission. This is XForms 1.1 feature, which allows you generate
> submission URL dynamically from instance data. Orbeon mentions that it
> wouldn't be hard to implement it, but currently it is not (see
> http://wiki.orbeon.com/forms/doc/developer-guide/orbeon-forms-xforms-compliance-matrix).
>
> Finally I decided, that I don't need ability to switch languages on fly. The
> language is fixed in user's session and if user changes it, the page is
> anyway reloaded. So I removed everything that was related to dynamic
> language change, which made the form even simpler (see attached
> i18n-simple.zip). Notice that language is currently fixed in resource
> instance's src attribute, but you could easily overcome this by:
> 1) modifying the form on-fly before giving it to XForms engine (we use XSL
> stylesheets for that),
> 2) specifying in instance's src attribute an URL to a script, that returns
> correct resource file based on language in user's session. You might need to
> set up cookie forwarding for this to work (I've done that).
>
> Now the thing why I wrote this e-mail. I still don't like the solution,
> because simple form is now split into several files - form itself and
> resource file for each language. While this has good points (you can add new
> languages without modifying the original form), it makes deployment and
> distribution of forms much more hassle than it used to be. My dream would be
> that everything is in one file, simple and elegant (see attached
> i18n-deam.zip):
> 1) current language is indicated by xml:lang attribute of xhtml:html tag
> (you could use AVT in there in Orbeon):
> <xhtml:html xml:lang="en">
> 2) all labels have xml:lang attribute. Only those labels are shown, whose
> xml:lang matches that of xhtml:html element.
> <xforms:label xml:lang="en">First name</xforms:label>
> <xforms:label xml:lang="fr">Prénom</xforms:label>
>
> I think that I could implement that with pre-processing stylesheet, if
> changing language dynamically is not allowed.
>
> What is your take on this? Are there any drawbacks with some of the
> implementations, that I might have not thought of? Do you think my dream of
> simple internationalization of XForms will ever get implemented in Orbeon or
> in standard?
>
> Thanks for your attention,
>  Tambet
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws