cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject Re: Internationalization
Date Mon, 11 Dec 2000 11:36:25 GMT
Conny,
Is there a discussion (or) plan to make small jar files (either C1 or C2) available for download
(or added to the xml-cocoon\lib in CVS)? To make it easier for people to use components like
the
i18n Transformer/Processor. IMHO, i18n Transformer/Processor is very important for any
non-trivial, decent-sized site.

Thanks,
dims

--- Conny Krappatsch <conny@smb-tec.com> wrote:
> On Sat, 09 Dec 2000 23:00:49 +0100
> Giacomo Pati <giacomo@apache.org> wrote:
> 
> > Hi Conny
> > 
> > Could you please post the proposal to this list, too.
> > 
> > Thakns
> > 
> > Giacomo
> > 
> > Conny Krappatsch wrote:
> 
> Here it comes (original message by Gerd Müller):
> 
> > Hi all,
> >
> > I've rewised the i18n proposal again and included also the suggestions
> > made by Lassi Immonen and Konstantin Piroumian. I think, the proposal
> > is now almost complete. Comments are always welcome.
> 
> > Best Regards,
> > Gerd
> 
> 
> 
> -- 
> ______________________________________________________________________
> Conny Krappatsch                              mailto:conny@smb-tec.com
> SMB GmbH                                        http://www.smb-tec.com
> 
> 
> 
> > 
> 1. Overview
> ------------
>    
>    This document describes an aproach for internationalization of XML
>    documents within Cocoon 1/2. It introduces some tags to markup text 
>    that should be translated and a format for dictionaries.
> 
>    The namespace of internationalization is defined as follows:
> 
>    xmlns:i18n="http://www.infozone-group.org/i18n"
> 
> 
> 2. Markup content for translation
> ---------------------------------
> 
>     2.1. Text
>     .........
>     
>     To translate simple text we use the <i18n:translate> tag:
> 
>         <i18n:translate>
>             [[text] | <i18n:text [i18n:key="a key"]>[text]</i18n:text>]
>             [<i18n:param>[text]</i18m:param>]*
>         </i18n:translate>
> 
>     The text that should be translated may either been placed between the 
>     <i18n:translate>-tags, or between the <i18n:text>-tags. The first 
>     method is for convenience only and should be used with care. 
>     
>     The 'i18n:key' attribute can be used to specify a special key for
>     the dictionary. Normally the text itself is used as the key to find
>     the translation in the dictionary. If we specify the attribute this
>     key is used to find the translation. 
>     
>     Optionally we can specify some <i18n:param>-tags which contain 
>     parameters. The values of these parameters will be inserted into the 
>     translated text, replacing some placeholders. Placeholders have the 
>     following syntax:
>     
>         \{[0-9]+\}
>         
>     An example:
>     
>     We specify the following tags in our document:
>     
>         <i18n:translate>
>             <i18n:text>Some {0} was inserted {1}.</i18n:text>
>             <i18n:param>text</i18n:param>
>             <i18n:param>here</i18n:param>
>         </i18n:translate>
>     
>     Now we want to translate this into German.
>     First, the processor will look into the dictionary, we specified, for 
>     the string:
> 
>         Some {0} was inserted {1}.
>         
>     It finds the string and translates it to German:
>         
>         Etwas {0} wurde {1} eingesetzt.
>     
>     Now the processor will replace the parameters. {0} will be replaced 
>     with "text" and {1} with "here". This results in:
>     
>         Etwas text wurde here eingesetzt.
>         
>     As we see, it is sometimes necessary to translate the parameters 
>     as well, since "here" is not a German word and "text" should be written 
>     uppercase. This can simply be done by marking up the parameters with
>     <i18n:translate> again:
> 
>         <i18n:translate>
>             <i18n:text>Some {0} was inserted {1}.</i18n:text>
>             <i18n:param>
>                 <i18n:translate>text</i18n:translate>
>             </i18n:param>
>             <i18n:param>
>                 <i18n:translate>here</i18n:translate>
>             </i18n:param>
>         </i18n:translate>
>     
> 
>     2.2. Attributes
>     ...............
>     
>     Additionally we can translate Attributes. This is very useful for 
>     HTML-forms since labels of buttons are set via an attribute in 
>     HTML. To translate attributes of a tag, add an additional attribute 
>     named 'i18n:attr' containing a list of attributes, which should be 
>     translated, separated by spaces.
>     
>     An example:
>         
>         <INPUT type="submit" value="Submit" i18n:attr="value"/>
>     
>     The attribute, which will be translated is 'value'. We must not 
>     enclose the tag, which contains the attribute to translate, in
>     <i18n:translate>-tags. If doing so, the tag will be removed and 
>     replaced with a text node. Parameter replacement is not available 
>     for attributes at this time.
> 
> 
> 3. Dictionaries
> ---------------
>     
>     Dictionaries contain the translations for the text to be translated.
>     They consist of a list of entries, where each entry specifies the
>     translation(s) for a key. An entry may contain the translation for
>     various languages. An example:
>     
>         <dictionary>
>             <entry>
>                 <key>
>                     Some {0} was inserted {1}.
>                 </key>
>                 <translation lang="de"> 
>                     Etwas {0} wurde {1} eingesetzt.
>                 </translation>
>             </entry>
>         </dictionary>
>     
>     For each text, we want to translate, we must provide a key, where
>     the key is either text as we've wrote it in the document or the value
>     of the 'i18n:key' attribute. The key must be written exactly like in 
>     the document, including spaces, linefeeds, etc.
>     
>     Then we must enter a translation for the text with the <translation>-tag,
>     where the 'lang'-attribute specifies the language of the translated
>     text. If the text contains placeholders, they'll be replaced at the 
>     correct places in the translation with the given parameters.
>     
>     We may also include a dictionary in another to have different 
>     dictionaries for different languages:
>     
>         <include href="other_dict_de.xml" [lang="de"]/>
>         <import href="other_dict_fr.xml" [lang="fr"]/>
>     
>     Now all entries from the included dictionaries are used too for 
>     translation. In case of double definition of entires the following
>     rules apply:
>     
>     - included entires take precedence over the enties of the including
>       dictionary
>     - the entries of the importing dictionary take precedence over the
>       imported entries
>       
>     The 'lang'-attribute is optional and specifies that the referenced
>     dictionary contains only translations for the given language. Thus
>     the i18n-processor/-transformer ignores the include/import instruction
>     if this language is not needed to translate some text.
> 
> 
> 5. How to specify the translation language
> ------------------------------------------
> 
>     There are three ways to specify into which language a document should
>     be translated:    
>     
>         1. Enter it as the HTTP-parameter "i18n:lang" in the URL or send it 
>            within a HTTP-form.
>         2. Put it into a cookie named "i18n:lang".
>         3. Put it into the current HTTP-session using the key "i18n:lang".
>         
>     Precedence is as written, so if you have specified a cookie and a 
>     HTTP-parameter, the HTTP-parameter will be used rather than the cookie, 
>     whilst the cookie would be used rather than the session-entry.
> 
> 
> 5. Setting up Cocoon
> --------------------
> 
>     5.1. Cocoon 1
>     .............
>     
>     In Cocoon 1 the internationalization is implementated as a processor.
>     
>     You need to add the following line to the Cocoon properties file to
>     register the processor:
>     
>         processor.type.i18n = org.infozone.ui.i18n.I18NProcessor
> 
>     To translate a document you'll need to add the following processing
>     instructions to the document:
> 
>         <?cocoon-process type="i18n"?>
>         <?i18n-dictionary href="my_dictionary.xml"?>
>         
>     The first instruction starts the processor, the second is used by the
>     processor to determine which dictionary should be used for this
>     document.
> 
> 
>     5.2. Cocoon 2
>     .............    
>     
>     In Cocoon 2 the internationalization is implementated as a transformer.
>     
>     You need to add the following line to the transformer section of the
>     Cocoon 2 sitemap to register the transformer:
>     
> 
=== message truncated ===


=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/

Mime
View raw message