W3C home > Mailing lists > Public > www-forms@w3.org > July 2010

Re: XForms i18n

From: Swithun Crowe <swithun@swithun.servebeer.com>
Date: Tue, 20 Jul 2010 10:36:02 +0100 (BST)
To: www-forms@w3.org
Message-ID: <alpine.LNX.2.00.1007201013400.25836@swithun.servebeer.com>

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>

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

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

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

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

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']"/>

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.

Received on Tuesday, 20 July 2010 09:31:05 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:23 UTC