- From: Swithun Crowe <swithun@swithun.servebeer.com>
- Date: Tue, 20 Jul 2010 10:36:02 +0100 (BST)
- To: www-forms@w3.org
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.
Received on Tuesday, 20 July 2010 09:31:05 UTC