XSLTools

Change of docs/labels.html

541:3a26a4f4272e
docs/labels.html
     1.1 --- a/docs/labels.html	Tue Nov 28 22:30:38 2006 +0000
     1.2 +++ b/docs/labels.html	Wed Dec 20 00:16:54 2006 +0000
     1.3 @@ -42,7 +42,7 @@
     1.4  to produce translated labels, we must first define a <a href="internationalisation.html#PreparingTheTranslations">translations file</a> as described in the <a href="internationalisation.html">"Internationalisation"</a> document; this file can be saved alongside our other resources with the name&nbsp;<code>translations.xml</code>, and its contents can be defined as follows:</p><pre>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;<br />&lt;translations&gt;<br />  &lt;locale&gt;<br />    &lt;code value="nb"/&gt;<br />    &lt;code value="nb_NO"/&gt;<br />    &lt;translation value="(Not selected)"&gt;(Ikke valgt)&lt;/translation&gt;<br />    &lt;translation value="Important"&gt;Viktig&lt;/translation&gt;<br />    &lt;translation value="Not important"&gt;Ikke viktig&lt;/translation&gt;<br />    &lt;translation value="Personal"&gt;Personlig&lt;/translation&gt;<br />  &lt;/locale&gt;<br />&lt;/translations&gt;</pre><p>To make use of this file, we must add additional references in the Web resource's attributes:</p><pre>    document_resources = {<br />        "types" : "structure_types_label.xml",<br />        <span style="font-weight: bold;">"translations" : "translations.xml"</span><br />        }</pre><p>And to introduce the translation mechanisms into the output production, we must modify the resource further:</p><pre>        # Complete the response.<br /><br />        <span style="font-weight: bold;">stylesheet_parameters["locale"] = trans.get_content_languages()[0]</span><br />        self.send_output(trans, [trans_xsl], structure, stylesheet_parameters,<br />            <span style="font-weight: bold;">references={"translations" : self.prepare_document("translations")}</span>)</pre><p>Here, we define a&nbsp;<code>locale</code>
     1.5  parameter for the output stylesheet using the first language specified
     1.6  in each user's browser's language preferences. Then, we add a reference
     1.7 -to the translations document specified above.</p><p>Finally, we have to change the template to make use of the translations:</p><pre>  &lt;p&gt;<br />    Item type:<br />    &lt;select template:multiple-choice-list-field="type,type-enum,value" name="..." multiple="multiple"<br />      onchange="requestUpdate(<br />        'comments',<br />        '{template:list-attribute('type-enum', 'value')}',<br />        '{template:other-elements(../options)}',<br />        '{template:child-attribute('value', template:child-element('comment', 1, template:other-elements(../options)))}',<br />        '/structure/item/options')"&gt;<br />      &lt;option template:multiple-choice-list-value="type-enum,value,selected<span style="font-weight: bold;">,template:i18n(text())</span>" value="..." /&gt;<br />    &lt;/select&gt;<br />  &lt;/p&gt;</pre><p>Note that we use the&nbsp;<a href="../apidocs/public/XSLForms.Output-module.html#i18n"><code>template:i18n</code></a> extension function to modify the text found in each&nbsp;<code>type-enum</code> element in the types document. The usage of this function is described in the&nbsp;<a href="../apidocs/public/XSLForms.Output-module.html">extension function API documentation</a>.</p><p>Now, upon adding items in the application, if the browser is set up appropriately - in this case using&nbsp;<code>Norwegian Bokm&aring;l [nb]</code>&nbsp;as the first choice of language - the item types will appear translated in the final output.</p>
     1.8 +to the translations document specified above.</p><p>Finally, we have to change the template to make use of the translations:</p><pre>  &lt;p&gt;<br />    Item type:<br />    &lt;select name="..." template:multiple-choice-list-field="type,type-enum,value" multiple="multiple"&gt;<br />      &lt;option template:multiple-choice-list-value="type-enum,value,selected<span style="font-weight: bold;">,template:i18n(text())</span>" value="..." /&gt;<br />    &lt;/select&gt;<br />  &lt;/p&gt;</pre><p>Note that we use the&nbsp;<a href="../apidocs/public/XSLForms.Output-module.html#i18n"><code>template:i18n</code></a> extension function to modify the text found in each&nbsp;<code>type-enum</code> element in the types document. The usage of this function is described in the&nbsp;<a href="../apidocs/public/XSLForms.Output-module.html">extension function API documentation</a>.</p><p>Now, upon adding items in the application, if the browser is set up appropriately - in this case using&nbsp;<code>Norwegian Bokm&aring;l [nb]</code>&nbsp;as the first choice of language - the item types will appear translated in the final output.</p>
     1.9  <h2>Further Reading</h2>
    1.10  <p>Now that we have designed and implemented a simple application, it
    1.11  may be worth reading some <a href="advice.html">recommendations</a>