# HG changeset patch # User paulb # Date 1142620023 0 # Node ID 6dba385935df8d44daded53ddec5fff0b90bfc60 # Parent fcb2735f7f194501db77bc664c6a3bfda5df3f0e [project @ 2006-03-17 18:27:03 by paulb] Added expression-based template:i18n annotations to the documentation. Added more notes about how values may be translated in templates. diff -r fcb2735f7f19 -r 6dba385935df docs/internationalisation.html --- a/docs/internationalisation.html Fri Mar 17 18:07:19 2006 +0000 +++ b/docs/internationalisation.html Fri Mar 17 18:27:03 2006 +0000 @@ -23,9 +23,12 @@ would resemble the following output document fragment:

<h1>Systemkonfigurasjon</h1>

Consequently, a translation has been inserted in place of the original text. In cases where no translation could be found, the original contents of the -element would be preserved.

It is also possible to employ a +element would be preserved.

Named Translations

It is also possible to employ a specific translation as opposed to the text which just happen to reside -inside an element; for example:

<h1 template:i18n="sysconfig">System Configurator</h1>

Here, instead of taking the exact text System Configurator as the "token" to be used to find a translation, we instead use the token with the name sysconfig. The effect, providing that the translation of sysconfig is Systemkonfigurasjon, would be the same as the result given above.

See the template:i18n section of the "Template Attribute Reference" document for details of this annotation.

Translating Attributes

Consider the following document fragment:

<input type="submit" name="update" value="Update!"/>

In order to translate the label of this particular form control to another language, we must modify the value attribute as follows:

<input type="submit" name="update" value="{template:i18n('Update!')}"/>

Here, +inside an element; for example:

<h1 template:i18n="sysconfig">System Configurator</h1>

Here, instead of taking the exact text System Configurator as the "token" to be used to find a translation, we instead use the token with the name sysconfig. The effect, providing that the translation of sysconfig is Systemkonfigurasjon, would be the same as the result given above.

Value Translations

In cases where the value being translated is not known before a document is to be displayed, one can either use the template:i18n extension function (as described below), special features of other annotations (such as template:multiple-choice-value), or expression-based translations, where an XPath expression is supplied within the annotation.

Here is an example for translating a multiple-choice field's values:

<select template:multiple-choice-field="-,type" name="..." value="...">
<option template:multiple-choice-value="type-enum,type,selected,template:i18n(@type)" value="..."/>
</select>

Note that this actually uses the template:i18n extension function in conjunction with the annotation's support for separate labels.

Here is how this might be done using an expression-based translation:

<select template:multiple-choice-field="-,type" name="..." value="...">
<option template:i18n="{@type}" template:multiple-choice-value="type-enum,type,selected" value="..."/>
</select>

In the above multiple-choice field definition, a range of values are presented that originates from type attributes on a number of type-enum +elements. Instead of just presenting the raw values as the labels for +the resulting pull-down menu, it is possible to override the +underlying template:value mechanism and provide a translation instead.

See the template:i18n section of the "Template Attribute Reference" document for details of this annotation.

Translating Attributes

Consider the following document fragment:

<input type="submit" name="update" value="Update!"/>

In order to translate the label of this particular form control to another language, we must modify the value attribute as follows:

<input type="submit" name="update" value="{template:i18n('Update!')}"/>

Here, we insert an expression inside the attribute whose result will be inserted in place of the expression. Note that for non-template attributes, the expression must reside between { and } characters for the evaluation to take place. The anticipated result might resemble something like the following:

<input type="submit" name="update" value="Oppdatér"/>

Where diff -r fcb2735f7f19 -r 6dba385935df docs/reference.html --- a/docs/reference.html Fri Mar 17 18:07:19 2006 +0000 +++ b/docs/reference.html Fri Mar 17 18:27:03 2006 +0000 @@ -16,7 +16,7 @@ attribute is used to translate the textual contents of an element to another language where additional parameters specifying the language and the whereabouts of the translations have been provided to the -stylesheet in the output generation process.

Example:

<span template:i18n="-">Hello</span>

In this example, the contents of the span element would be replaced with an appropriate translation for the text Hello.

Example:

<span template:i18n="hello">Hello</span>

In this example, the contents of the span element would be replaced with an appropriate translation using the token hello as a key in the translation dictionary.

Syntax:

-|token

See the "Internationalisation" document for more information on this attribute.

Initialisation Annotations

The annotation attributes in this section control the initialisation of documents where this is done by the XSLForms toolkit.

template:init

This attribute controls the creation of elements in the initialisation process and is used together with template:element. For each element name listed in a template:element annotation, the corresponding value in a template:init annotation states whether or how such elements are to be initialised.

Example:

<p template:element="item" template:init="no">
Such item elements will not be created automatically when the document is initialised.
</p>

Example:

<p template:element="first,second,third" template:init="yes,yes,no">
The first and second elements will be created automatically when the document is initialised.
No third elements will be created automatically when the document is initialised.
</p>

Syntax:

yes|no|auto[,yes|no|auto[,...]]

Here, yes means that an element will be created automatically, no means that an element will not be created automatically (relying on the existence of such elements from before), and auto +stylesheet in the output generation process.

Example:

<span template:i18n="-">Hello</span>

In this example, the contents of the span element would be replaced with an appropriate translation for the text Hello.

Example:

<span template:i18n="hello">Hello</span>

In this example, the contents of the span element would be replaced with an appropriate translation using the token hello as a key in the translation dictionary.

Example:

<span template:i18n="{$this-value}">Hello</span>

In this example, the value of the special template variable $this-value is used as a key in the translation dictionary.

Syntax:

-|{expression}|token

See the "Internationalisation" document for more information on this attribute.

Initialisation Annotations

The annotation attributes in this section control the initialisation of documents where this is done by the XSLForms toolkit.

template:init

This attribute controls the creation of elements in the initialisation process and is used together with template:element. For each element name listed in a template:element annotation, the corresponding value in a template:init annotation states whether or how such elements are to be initialised.

Example:

<p template:element="item" template:init="no">
Such item elements will not be created automatically when the document is initialised.
</p>

Example:

<p template:element="first,second,third" template:init="yes,yes,no">
The first and second elements will be created automatically when the document is initialised.
No third elements will be created automatically when the document is initialised.
</p>

Syntax:

yes|no|auto[,yes|no|auto[,...]]

Here, yes means that an element will be created automatically, no means that an element will not be created automatically (relying on the existence of such elements from before), and auto means that the initialisation process will attempt to guess whether an element should be created automatically (by looking for selectors which use the element's name and only creating elements where no such