XForms i18n

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XForms i18n

Bugzilla from ku.b@gmx.de
Is XForms allowed to ignore xml:lang attributes?

What I want:
one document containing data, layout and translations. Splitting into
several documents is no option.

What I tried:
<xf:select1 ref="/my/model/some_value">
  <xf:label lang="en_US">Label</xf:label>
  <xf:label lang="de_DE">Aufkleber</xf:label>
  ...
</xf:select1>

Result in FF-XForms-0.8.7:
"Label" and "Aufkleber" appear both in the UI.

Naively expected Result:
For a browser setup to "de_DE" only "Aufkleber" is shown. Others
setups show just "Label".


Can someone please shed some light on this situation.
Is my translation approach correct?
If not, are there alternatives?


kind regards
Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org


Reply | Threaded
Open this post in threaded view
|

Re: XForms i18n

Swithun Crowe
Hello

KB> What I want: one document containing data, layout and translations.
KB> Splitting into several documents is no option.

I don't know if the naive approach will work, though it would be nice if
it did.

What you could do is have three extra instances. One will hold a list of
possible languages. Another will hold the selected language. And the third
will hold all your I18N strings. Something like:

<xf:instance id="langs">
  <langs xmlns="">
    <lang id="en_US">American English</lang>
    <lang id="de_DE">Deutsch</lang>
    ...
  </langs>
</xf:instance>

<xf:instance id="lang">
  <lang xmlns="">en_US</lang>
</xf:instance>

<xf:instance id="strings">
  <strings xmlns="">
    <string lang="en_US" name="label">Label</string>
    <string lang="de_DE" name="label">Aufkleber</string>
    ...
  </strings>
</xf:instance>

And then have a select1 control where the user selects their preferred
language:

<xf:select1 ref="instance('lang')">
  <xf:label>Select language</xf:label>
  <xf:itemset nodeset="instance('langs')/lang">
    <xf:label ref="."/>
    <xf:value ref="@id"/>
  </xf:itemset>
</xf:select1>

and then for your internationalised controls, have something like:

<xf:select1 ref="/my/model/some_value">
  <xf:label ref="instance('strings')/string[@lang=instance('lang')][@name='label']"/>
  ...
</xf:select1>

I haven't tested the code, but something along those lines should work. I
agree it doesn't give special status to the @lang attribute, so there
might be a better approach where the browser/implementation does the work.

Swithun.

Reply | Threaded
Open this post in threaded view
|

Re: XForms i18n

Bugzilla from ku.b@gmx.de
Am 20.07.10, 10:36 +0100 schrieb Swithun Crowe:
...

Thanks, your example works in FF.

kind regards
Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org


Reply | Threaded
Open this post in threaded view
|

Re: XForms i18n

Tambet Matiisen
In reply to this post by Swithun Crowe
While certainly conforming to standard, this approach is much more
verbose than the one proposed in original e-mail. I remember discussion,
that XForms schema allows <xforms:label> several times inside control
exactly for this reason - to allow labels, help texts and alerts in
multiple languages. Do future versions of XForms specifications address
this issue? Does any of the implementations already support xml:lang
attribute for labels?

Thanks in advance,
  Tambet

Swithun Crowe wrote:

> Hello
>
> KB> What I want: one document containing data, layout and translations.
> KB> Splitting into several documents is no option.
>
> I don't know if the naive approach will work, though it would be nice if
> it did.
>
> What you could do is have three extra instances. One will hold a list of
> possible languages. Another will hold the selected language. And the third
> will hold all your I18N strings. Something like:
>
> <xf:instance id="langs">
>   <langs xmlns="">
>     <lang id="en_US">American English</lang>
>     <lang id="de_DE">Deutsch</lang>
>     ...
>   </langs>
> </xf:instance>
>
> <xf:instance id="lang">
>   <lang xmlns="">en_US</lang>
> </xf:instance>
>
> <xf:instance id="strings">
>   <strings xmlns="">
>     <string lang="en_US" name="label">Label</string>
>     <string lang="de_DE" name="label">Aufkleber</string>
>     ...
>   </strings>
> </xf:instance>
>
> And then have a select1 control where the user selects their preferred
> language:
>
> <xf:select1 ref="instance('lang')">
>   <xf:label>Select language</xf:label>
>   <xf:itemset nodeset="instance('langs')/lang">
>     <xf:label ref="."/>
>     <xf:value ref="@id"/>
>   </xf:itemset>
> </xf:select1>
>
> and then for your internationalised controls, have something like:
>
> <xf:select1 ref="/my/model/some_value">
>   <xf:label ref="instance('strings')/string[@lang=instance('lang')][@name='label']"/>
>   ...
> </xf:select1>
>
> I haven't tested the code, but something along those lines should work. I
> agree it doesn't give special status to the @lang attribute, so there
> might be a better approach where the browser/implementation does the work.
>
> Swithun.
>
>