cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Updated: I18n Transformer
Date Tue, 04 Oct 2005 14:05:42 GMT
A document has been updated:

Document ID: 463
Branch: main
Language: default
Name: I18n Transformer (unchanged)
Document Type: Document (unchanged)
Updated on: 10/4/05 2:05:35 PM
Updated by: Helma van der Linden

A new version has been created, state: publish

This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 20672 bytes (previous version: 20640 bytes)
Content diff:
(16 equal lines skipped)
    <p>This approach for internationalization (further - i18n) of XML documents
    within Cocoon is based on a transformer -
--- <a href="apidocs/org/apache/cocoon/transformation/I18nTransformer.html">
+++ <a href="">
    <tt>I18nTransformer</tt> </a> , which uses XML dictionaries for all
    multilingual data. The namespace URI of i18n transformer is defined as follows:
(22 equal lines skipped)
    <p>A simple example of i18n markup:</p>
--- <pre>
--- &lt;para title="first" name="article"  i18n:attr="title name"&gt;
+++ <pre>&lt;para title="first" name="article"  i18n:attr="title name"&gt;
      &lt;i18n:text&gt;This text will be translated.&lt;/i18n:text&gt;
(16 equal lines skipped)
    <p>Tags list</p>
+++ <tbody>
(51 equal lines skipped)
    <p>Formats numbers, currencies and percent in localized manner</p>
+++ </tbody>
    <h2 id="i18n_text">i18n:text</h2>
    <p>To translate some simple text we use the <tt>&lt;i18n:text&gt;</tt>
--- <pre>
--- &lt;i18n:text&gt;Text to be translated&lt;/i18n:text&gt;</pre>
+++ <pre>&lt;i18n:text&gt;Text to be translated&lt;/i18n:text&gt;</pre>
    <p>The text between the <tt>&lt;i18n:text&gt;</tt>-tags is used
as a key to find
    the translation in the dictionary.</p>
(4 equal lines skipped)
    find the translation and the text itself is used as the default value, if no
    translation can be found.</p>
--- <pre>
--- &lt;i18n:text i18n:key="key_text"&gt;Default value&lt;/i18n:text&gt;</pre>
+++ <pre>&lt;i18n:text i18n:key="key_text"&gt;Default value&lt;/i18n:text&gt;</pre>
    <p>Messages can be taken from multiple dictionaries. The dictionaries are
    configured in the sitemap (see further on), and each dictionary is assigned an
    id. There is one dictionary that serves as the default one. To translate a key
    using a non-default dictionary, mention the id of the dictionary in an
    i18n:catalogue attribute:</p>
--- <pre>
--- &lt;i18n:text i18n:catalogue="menu"&gt;key_text&lt;/i18n:text&gt;</pre>
+++ <pre>&lt;i18n:text i18n:catalogue="menu"&gt;key_text&lt;/i18n:text&gt;</pre>
    <h2 id="i18n_translate">Translation with param substitution</h2>
(29 equal lines skipped)
    can simply be done by marking up the parameters with <tt>&lt;i18n:text&gt;</tt>
--- <pre>
--- &lt;i18n:translate&gt;
+++ <pre>&lt;i18n:translate&gt;
        &lt;i18n:text&gt;Some {0} was inserted {1}.&lt;/i18n:text&gt;
(17 equal lines skipped)
    list of attributes, which should be translated, separated by spaces. An example:
--- <pre>
--- &lt;INPUT type="submit" value="Submit" i18n:attr="value"/&gt;</pre>
+++ <pre>&lt;INPUT type="submit" value="Submit" i18n:attr="value"/&gt;</pre>
    <p>The attribute, which will be translated is 'value'. Parameter replacement is
    not available for attributes at this time.</p>
(7 equal lines skipped)
    multiple dictionaries. To use a specific dictionary, add the id of the
    dictionary before the key, separated by a colon:</p>
--- <pre>
--- &lt;INPUT type="submit" value="form:Submit" i18n:attr="value"/&gt;</pre>
+++ <pre>&lt;INPUT type="submit" value="form:Submit" i18n:attr="value"/&gt;</pre>
    <h2 id="i18n_date">Date, time and number formatting</h2>
(60 equal lines skipped)
    <tt>type</tt> attribute must be used with params to indicate the param type
    (date, number, currency, ...). Default type is <tt>string</tt>.</p>
--- <pre>
--- &lt;i18n:translate&gt;
+++ <pre>&lt;i18n:translate&gt;
        You have to pay {0} for {1} pounds or {2} of your profit. Valid from {3}
(17 equal lines skipped)
    <p>A single message catalogue file contains translations for a particular
    language, e.g.:</p>
--- <pre>
--- &lt;?xml version="1.0"?&gt;
+++ <pre>&lt;?xml version="1.0"?&gt;
      &lt;!-- message catalogue file for locale ... --&gt;
      &lt;catalogue xml:lang="locale"&gt;
             &lt;message key="key"&gt;text&lt;/message&gt;
(40 equal lines skipped)
    <h2>Sitemap configuration</h2>
--- <pre>
--- &lt;map:transformer name="i18n"
+++ <pre>&lt;map:transformer name="i18n"
         &lt;catalogues default="messages"&gt;
(34 equal lines skipped)
    <p>To use the transformer in a pipeline, simply specify it in a particular
    transform and indicate the needed locale. eg:</p>
--- <pre>
--- &lt;map:match pattern="file"&gt;
+++ <pre>&lt;map:match pattern="file"&gt;
            &lt;map:generate src="file.xml"/&gt;
             &lt;map:transform type="i18n"&gt;
               &lt;map:parameter name="locale" value="en_AU"/&gt;
(56 equal lines skipped)
    <p>Command line for Xalan (Of course, Xerces and Xalan must be in your
--- <pre>
--- java org.apache.xalan.xslt.Process -IN simple_dict.xml -XSL merge.xsl \
+++ <pre>java org.apache.xalan.xslt.Process -IN simple_dict.xml -XSL merge.xsl \
    -OUT simple_dict_es.xml -PARAM mode keys -PARAM new-lang es -PARAM keep-lang en
(12 equal lines skipped)
    <p>Use the same stylesheet for this purpose with this params:</p>
--- <pre>
--- mode = merge
+++ <pre>mode = merge
    new-lang = es
    new-dict = simple_dict_es.xml
    <p>Command line for Xalan:</p>
--- <pre>
--- java org.apache.xalan.xslt.Process -IN simple_dict.xml -XSL merge.xsl \
+++ <pre>java org.apache.xalan.xslt.Process -IN simple_dict.xml -XSL merge.xsl \
    -OUT simple_dict_new.xml -PARAM mode merge -PARAM new-lang es \
    -PARAM new-dict simple_dict_es.xml
(27 equal lines skipped)

no changes

no changes

Custom Fields
no changes

no changes

View raw message