Multilingual Forms and Applications

Steven Pemberton, CWI and W3C, Amsterdam

URLs

Many people (webmasters as well as users), think that a URL is the address of a single document

http://www.w3.org/2011/03/w3ctrack-pr.html

Example

Press release

This press release is avalable in English and French, and which one you get depends on how you have specified your languages in the browser.

HTTP and Content Negotiation

HTTP allows content negotiation

Along with the URL, the browser sends details of what is acceptable:

HTTP and Content Negotiation

All of these have as option a wild card "*", to signify that the explicit choices given are preferences, but anything else is acceptable.

The server then uses those details to find (or create) something suitable.

Example

There are a number of services which will tell you what your browser sends. For instance:

Yoyo

Eric Giguere

What if there isn't anything suitable?

Everyone has met the '404' response. This is the reply that there is nothing at the URL given.

Along with a 404 response, it is possible to send any document (that matches the content negotiation parameters). Usually for a 404 this is an error message of some sort, but it doesn't have to be.

404

Some servers (or intermediaries) wilfully do not send a 404, but give you something else instead. This is BAD!

One reason that it is bad is that it means you can no longer use automatic link checkers to see if any of your links are broken.

406 Not Acceptable

But if there is something at the URL, but that doesn't match the content negotiation values, the server is supposed to send a 406 Not Acceptable reply.

This means that there is something at the URI in question, but nothing that matches your Content Negotiation parameters.

406

Just as with 404, the server can send an error message, or a list of possible documents at that URL that are available, or even one of those documents.

This is OK as long as it is accompanied by the 406 response code, just as with 404.

Google

www.google.com

If you follow this link in Italy, then regardless of what you have specified in your language settings, you will be redirected to the Italian version of Google. (This may actually be different in Chrome!)

Google

Google uses your IP address to decide where you are, and then serve you a version 'suitable' for that region.

Regardless of what you supply as acceptible languages!

(How do I know? In the early days they got it wrong, and I told them, and they actually replied.)

They add a extra mechanism: a cookie that specifies your one preferred language. This is also BAD, or at least very naughty.

Why?

Why do Google do this? Possibly to be helpful: It is exceedingly hard to set up your languages in a browser.

However, it is not friendly to ignore your language settings...

Other approaches

Many sites offer a button or control that sends you to a different language page (though often they conflate location with language, and it can be hard to tell which you should select).

For example: klm.com easyjet.com or ov-chipkaart.nl

Instead of sending you to another page, some do it using Javascript instead, changing the content of the page using Javascript assignments.

Multilingual content is hard to maintain

If you look at that last example (ov-chipkaart.nl), you'll see it is littered with mistakes.

Managing multi-lingual sites can be a nightmare, especially when you want the formatting to remain good.

XForms

XForms is a W3C technology, originally designed to be updated and easier to produce forms language for the web, because of its generality, it has evolved into a way of producing applications as well.

Example: to do

(Source)

Example: maps (46 lines of code)

(Source)

XForms Structure

XForms has a data model, where all data is stored, and in the body controls where data values can be input or output:

<model>
    <instance>
        <data xmlns="">
          <firstname/><surname/>
       </data>
   </instance>
</model>
 ...
<input ref="firstname"><label>First name</label></input>
 ...
<output ref="firstname"/>

Input and output

(Source)

Values can be calculated

<model>
   <instance>
       <data xmlns="">
          <height/><width/><depth/><volume/>
       </data>
   </instance>
   <bind nodeset="volume"
         calculate="../width*../height*../depth"/>
</model>

Volume example

(Source)

Controls are abstract

Here are three identical controls, just styled differently

(Source)

Data can be obtained from external sources

<model>
    <instance src="http://..."/>
</model>

And data can be written back to external sources.

And values can be output anywhere

<input ref="age">
    <label><output ref="age-text"/></label>
</input>

Example

(Source)

Languages file for Dutch

(Source)

Example

(Source)

The language file

(Source)

Implementations

There are many implementations of XForms:

And there are many types of implementation:

Experience

Declarative applications require much less work to produce

Experience has shown that an application requires about an order of magnitude less work to produce in XForms.

Conclusion

Using only generic features of XForms (i.e. not designed per se for internationalisation or localisation) it is possible to create a sort of language sheets facility (comparable to style sheets) that enables you to have just one document that works for many languages.

More on XForms: XForms 1.1 Tutorial