Metadata controls and xml lang

From W3C XForms Group Wiki (Public)

The @xml:lang attribute can be applied to metadata controls labelm, help, hint, alert, or message as follows

<label xml:lang="iso-language-code-values">

The effect of the @xml:lang attribute is to make the label or related control appear if and only if the language is the same as the explicit or implicit language of the page, as determined by the host language. As such, a given control may include multiple metadata control labels, one for each language lists.

The @xml:lang attribute is considered a sequence of NMTokens - this means that the attribute can have multiple languages specified in the attribute, each separated by white space. In such a case, the metadata control is displayed if and only if one of the languages so specified matches the implicit or explicit language of the page.

Listing 5 illustrates the use of @xml:lang for a label:

<xf:input ref="firstname">
    <xf:label lang="en-us en-uk en-ca">First Name</xf:label>
    <xf:label lang="fr">Prénom</xf:label>
    <xf:label lang="ru">Имя</xf:label>
    <xf:label lang="jp">最初の名前</xf:label>

Listing 5. Multiple language codes in a label.

In this case, the English label is used if the page is in US, British or Canadian English, the French label is used if the page is in French and so forth.

A metadata control that does not specify the language will be treated as the default case - it will be used if and only if there are no other metadata controls of the same type that more explicit match the language of the page. In the example in Listing 5, the German "Vorname" will be used only if the page of the language is not English, French, Russian or Japanese.