dims        01/05/16 07:41:07

  Modified:    webapp   sitemap.xmap
               webapp/docs/samples samples.xml
               xdocs    docs-book.xml site-book.xml
  Added:       webapp/i18n simple.xml simple.xsl simple.xsp sitemap.xmap
               webapp/i18n/translations simple_dict.xml
  Log:
  I18nTransformer docs and samples
  from Konstantin Piroumian ([EMAIL PROTECTED])
  
  Revision  Changes    Path
  1.4       +5 -0      xml-cocoon2/webapp/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/sitemap.xmap,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap.xmap      2001/05/15 11:34:24     1.3
  +++ sitemap.xmap      2001/05/16 14:40:46     1.4
  @@ -150,6 +150,11 @@
       <map:mount uri-prefix="protected" src="protected/" check-reload="yes"/>
      </map:match>
     </map:pipeline>
  +  <map:pipeline>
  +   <map:match pattern="i18n**">
  +    <map:mount uri-prefix="i18n" src="i18n/" check-reload="yes"/>
  +   </map:match>
  +  </map:pipeline>
    <map:pipeline>
   
      <map:match pattern="">
  
  
  
  1.2       +6 -0      xml-cocoon2/webapp/docs/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/docs/samples/samples.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- samples.xml       2001/05/09 20:50:13     1.1
  +++ samples.xml       2001/05/16 14:40:52     1.2
  @@ -79,6 +79,12 @@
      <sample name="Content Aggregation" href="news/aggregate.xsp">
       Sample for Transparent Content Aggregation.        
      </sample>
  +   <sample name="Simple Internationalization" href="i18n/simple.xml">
  +    Sample for Internationalization.        
  +   </sample>
  +   <sample name="XSP Internationalization" href="i18n/simple.xsp">
  +    Sample for Internationalization in an XSP.        
  +   </sample>
      <sample name="Simple SQL" href="sql/sql-page" xlink:role="dynamic">
       Simple SQL example. You should make sure that you have a database and
       table according to the conf/sitemap.xmap and the
  
  
  
  1.1                  xml-cocoon2/webapp/i18n/simple.xml
  
  Index: simple.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <root xmlns:i18n="http://apache.org/cocoon/i18n";>
        <title>
                <i18n:text>Hello, internationalization!</i18n:text>
        </title>
        <menu>
                <item>
                        <title><i18n:text>language</i18n:text></title>
                </item>
                <item>
                        <link>
                                
<href>?lang=<i18n:text>lang_id1</i18n:text></href>
                                <title>
                                        <i18n:text>language1</i18n:text>
                                </title>
                        </link>
                </item>
                <item>
                        <link>
                                
<href>?lang=<i18n:text>lang_id2</i18n:text></href>
                                <title>
                                        <i18n:text>language2</i18n:text>
                                </title>
                        </link>
                </item>
        </menu>
        <content>
                <para title="first" name="article" i18n:attr="title name">
                        <i18n:text i18n:key="a_key">article_text1</i18n:text>
                </para>
                <para title="second" name="article" i18n:attr="title name">
                        <i18n:text>article_text2</i18n:text>
                </para>
                <para title="third" name="article" i18n:attr="title name">
                        <i18n:translate>
                                <i18n:text>Hello, {0}! Glad to see 
you!</i18n:text>
                                <i18n:param name="username">
                                        <i18n:text>Kot</i18n:text>
                                </i18n:param>
                        </i18n:translate>
                </para>
                <para title="forth" name="article" i18n:attr="title name">
                        <i18n:translate>
                                One: {0}, two: {1}, {2}! {3}
                                This is another line {3}
                                <i18n:param 
name="one"><i18n:text>one</i18n:text></i18n:param>
                                <i18n:param 
name="two"><i18n:text>two</i18n:text></i18n:param>
                                <i18n:param name="third">baby</i18n:param>
                                <i18n:param name="forth">/n</i18n:param>
                        </i18n:translate>
                </para>
        </content>
        <bottom>
                <copyright>
                        <i18n:text>copyright</i18n:text>
                </copyright>
        </bottom>
  </root>
  
  
  
  1.1                  xml-cocoon2/webapp/i18n/simple.xsl
  
  Index: simple.xsl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:template match="root">
                <html>
                        <head>
                                <title>
                                        <xsl:value-of select="title"/>
                                </title>
                        </head>
                        <body bgcolor="white">
                                <h1>
                                        <font color="navy">
                                                <xsl:value-of select="title"/>
                                        </font>
                                </h1>
                                <h4><xsl:value-of select="sub-title"/></h4>
                                <xsl:apply-templates select="menu"/>
                                <hr align="left" noshade="noshade" size="1"/>
                                
                                <xsl:apply-templates select="content" />
                                
                                <hr align="left" noshade="noshade" size="1"/> 
                                <xsl:apply-templates select="bottom"/>
                        </body>
                </html>
        </xsl:template>
        
        <xsl:template match="menu">
                <font size="-1">
                        <xsl:for-each select="item">
                                <xsl:apply-templates select="."/>
                                <xsl:if test="position() != last()"><xsl:text> 
| </xsl:text></xsl:if>
                        </xsl:for-each>
                </font> 
        </xsl:template>
        
        <xsl:template match="link">
                <a href="{href}"><xsl:value-of 
select="normalize-space(title)"/></a>
        </xsl:template>
        
        <xsl:template match="item/title">
                <font color="maroon"><xsl:copy-of 
select="normalize-space(.)"/></font>
        </xsl:template>
        
        <xsl:template match="content">
                <xsl:apply-templates />
        </xsl:template>
        
        <xsl:template match="para">
                <p>
                        <font color="navy"><b><xsl:value-of select="position() 
div 2"/>. <xsl:value-of select="@name"/> </b>: <xsl:value-of 
select="@title"/></font><br/>
                        <font size="-1"><xsl:value-of select="."/></font>
                </p>    
        </xsl:template>
        
        <xsl:template match="bottom">
                <small><b><xsl:value-of select="copyright"/></b></small>        
        
        </xsl:template>
        
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/webapp/i18n/simple.xsp
  
  Index: simple.xsp
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"; 
xmlns:xsp-request="http://apache.org/xsp/request"; 
xmlns:i18n="http://apache.org/cocoon/i18n";>
  
  <xsp:structure>
        <xsp:include>java.text.MessageFormat</xsp:include>
  </xsp:structure>
  
  <xsp:logic>
        private static int count = 0;
  </xsp:logic>
  
  <root>
        <xsp-request:get-session />
        <xsp:logic>
                synchronized (this) {
                        count++;
                }
        
                String lang = <xsp-request:get-parameter name="lang"/>;
                if (lang != null) {
                        request.setAttribute("lang", lang);
                }
                
        </xsp:logic>
        <title>
                <i18n:text>Hello, internationalization!</i18n:text>
        </title>
        <sub-title>
                <i18n:translate>
                        <i18n:text>count_title</i18n:text>
                        <i18n:param><xsp:expr>count</xsp:expr></i18n:param>
                        <i18n:param><xsp:expr>new Date()</xsp:expr></i18n:param>
                </i18n:translate>
        </sub-title>
        <menu>
                <item>
                        <title><i18n:text>language</i18n:text></title>
                </item>
                <item>
                        <link>
                                
<href>?lang=<i18n:text>lang_id1</i18n:text></href>
                                <title>
                                        <i18n:text>language1</i18n:text>
                                </title>
                        </link>
                </item>
                <item>
                        <link>
                                
<href>?lang=<i18n:text>lang_id2</i18n:text></href>
                                <title>
                                        <i18n:text>language2</i18n:text>
                                </title>
                        </link>
                </item>
        </menu>
        <content>
                <para title="first" name="article" i18n:attr="title name">
                        <i18n:text i18n:key="a_key">article_text1</i18n:text>
                </para>
                <para title="second" name="article" i18n:attr="title name">
                        <i18n:text>article_text2</i18n:text>
                </para>
                <para title="third" name="article" i18n:attr="title name">
                        <i18n:translate>
                                <i18n:text>Hello, {0}! Glad to see 
you!</i18n:text>
                                <i18n:param 
name="username"><xsp-request:get-parameter name="user" default="none" 
as="string"/></i18n:param>
                        </i18n:translate>
                </para>
                <para title="forth" name="article" i18n:attr="title name">
                        <i18n:translate>
                                One: {0}, two: {1}, {2}! {3}
                                This is another line {3}
                                <i18n:param 
name="one"><i18n:text><xsp:expr>"ONE".toLowerCase()</xsp:expr></i18n:text></i18n:param>
                                <i18n:param 
name="two"><i18n:text>two</i18n:text></i18n:param>
                                <i18n:param name="third">baby</i18n:param>
                                <i18n:param name="forth">/n</i18n:param>
                        </i18n:translate>
                </para>
        </content>
        <bottom>
                <copyright>
                        <i18n:text>copyright</i18n:text>
                </copyright>
        </bottom>
  </root>
  
  </xsp:page>
  
  
  
  
  1.1                  xml-cocoon2/webapp/i18n/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
        <!-- =========================== Components 
================================ -->
        <map:components>
                <map:generators default="file"/>
                <map:transformers default="xslt">
                        <map:transformer name="i18n" 
src="org.apache.cocoon.transformation.I18nTransformer2">
                                <parameter name="available_lang_1" value="en"/>
                                <parameter name="available_lang_2" value="ru"/>
                                <parameter name="available_lang_3" value="de"/>
                        </map:transformer>
                </map:transformers>
                <map:readers default="resource"/>
                <map:serializers default="html"/>
                <map:selectors default="browser"/>
                <map:matchers default="wildcard">
                        <map:matcher name="wildcard" 
factory="org.apache.cocoon.matching.WildcardURIMatcherFactory"/>
                </map:matchers>
        </map:components>
        <!-- =========================== Pipelines 
================================= -->
        <map:pipelines>
                <map:pipeline>
                        <map:match pattern="**.xml">
                                <map:generate src="{1}.xml"/>
                                <map:transform type="i18n">
                                        <parameter name="src" 
value="translations/{1}_dict.xml"/>
                                </map:transform>
                                <map:transform src="simple.xsl"/>
                                <map:serialize/>
                        </map:match>
                        <map:match pattern="**.xsp">
                                <map:generate type="serverpages" src="{1}.xsp"/>
                                <map:transform type="i18n">
                                        <parameter name="src" 
value="translations/{1}_dict.xml"/>
                                </map:transform>
                                <map:transform src="simple.xsl"/>
                                <map:serialize/>
                        </map:match>
                        
                        <map:handle-errors>
                                <map:transform 
src="../stylesheets/system/error2html.xsl"/>
                                <map:serialize status-code="500"/>
                        </map:handle-errors>
                </map:pipeline>
        </map:pipelines>
  </map:sitemap>
  <!-- end of file -->
  
  
  
  1.1                  xml-cocoon2/webapp/i18n/translations/simple_dict.xml
  
  Index: simple_dict.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <translations>
  
        <!-- Language links -->
        <entry>
                <key>count_title</key>
                <translation lang="en">This page was accessed {0} times. Last 
at: {1}.</translation>
                <translation lang="ru">На эту страницу 
заходили {0} раз(а). В последний раз {1}.</translation>
                <translation lang="de">Dno {0}. Last {1}</translation>
        </entry>                
        <entry>
                <key>a_key</key>
                <translation lang="en">This is a key value.</translation>
                <translation lang="ru">Это значение по 
ключу.</translation>
                <translation lang="de">Das ist key value.</translation>
        </entry>        
        <entry>
                <key>lang_id1</key>
                <translation lang="en">ru</translation>
                <translation lang="ru">en</translation>
                <translation lang="de">en</translation>
        </entry>
        <entry> 
                <key>lang_id2</key>
                <translation lang="en">de</translation>
                <translation lang="ru">de</translation>
                <translation lang="de">ru</translation>
        </entry>                
        <entry>
                <key>language</key>
                <translation lang="en">English</translation>
                <translation lang="ru">Русский</translation>
                <translation lang="de">Deutch</translation>
        </entry>
        <entry>
                <key>language1</key>
                <translation lang="en">Russian</translation>
                <translation lang="ru">Английский</translation>
                <translation lang="de">Angliese</translation>
        </entry>
        <entry>
                <key>language2</key>
                <translation lang="en">German</translation>
                <translation lang="ru">Немецкий</translation>
                <translation lang="de">Russe</translation>
        </entry>        
  
        <entry>
                <key>Hello, internationalization!</key>
                <translation lang="en">Hello, 
internationalization!</translation>
                <translation lang="ru">Привет, 
многоязычность!</translation>
                <translation lang="de">Heil, 
Internazinalizionen!!!</translation>
        </entry>
        <entry>
                <key>first</key>
                <translation lang="en">First</translation>
                <translation lang="ru">Первый</translation>
                <translation lang="de">Erst</translation>
        </entry>
        <entry>
                <key>second</key>
                <translation lang="en">Second</translation>
                <translation lang="ru">Второй</translation>
                <translation lang="de">Zwiete</translation>
        </entry>        
        <entry>
                <key>third</key>
                <translation lang="en">Third</translation>
                <translation lang="ru">Третий</translation>
                <translation lang="de">Dreite</translation>
        </entry>                
        <entry>
                <key>forth</key>
                <translation lang="en">Forth</translation>
                <translation lang="ru">Четвертый</translation>
                <translation lang="de">Furthe</translation>
        </entry>                        
        <entry>
                <key>article</key>
                <translation lang="en">Article</translation>
                <translation lang="ru">Статья</translation>
                <translation lang="de">Artikkle</translation>           
        </entry>                
        <entry>
                <key>article_text1</key>
                <translation lang="en">This is a i18n paragraph.</translation>
                <translation lang="ru">Это 
интернационализированный абзац.</translation>
                <translation lang="de">How do you say it in German? 
:)</translation>            
        </entry>                
        <entry>
                <key>article_text2</key>
                <translation lang="en">This is another i18n paragraph and is 
also a cool one.</translation>
                <translation lang="ru">Это тоже 
интернационализированный абзац и такой же 
классный.</translation>
                <translation lang="de">How do you say it in German? 
:)</translation>            
        </entry>        
        <entry>
                <key>copyright</key>
                <translation lang="en">Copyright © 2001 Konstantin Piroumian 
Inc. No rights are reserved.</translation>
                <translation lang="ru">Авторские права © 2001 
Константин Пирумян. Ничто не 
защищено.</translation>
                <translation lang="de">Copyright © 2001 How do you say it in 
German? :)</translation>
        </entry>        
        <entry>
                <key>Hello, {0}! Glad to see you!</key>
                <translation lang="en">Hello, {0}! Glad to see 
you!</translation>
                <translation lang="ru">Привет, {0}! Рад тебя 
видеть!</translation>
                <translation lang="de">Heil, {0}! How do you say it in German? 
:)</translation>         
        </entry>                
        <entry>
                <key>Kot</key>
                <translation lang="en">Tomcat</translation>
                <translation lang="ru">Кот</translation>
                <translation lang="de">Kotten</translation>             
        </entry>                
        <entry>
                <key>none</key>
                <translation lang="en">None</translation>
                <translation lang="ru">Никто</translation>
                <translation lang="de">Nicht</translation>              
        </entry>        
        <entry>
                <key>one</key>
                <translation lang="en">one</translation>
                <translation lang="ru">раз</translation>
                <translation lang="de">ein</translation>                
        </entry>                
        <entry>
                <key>two</key>
                <translation lang="en">two</translation>
                <translation lang="ru">два</translation>
                <translation lang="de">zwein</translation>              
        </entry>                        
  </translations>
  
  
  1.2       +1 -0      xml-cocoon2/xdocs/docs-book.xml
  
  Index: docs-book.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/xdocs/docs-book.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- docs-book.xml     2001/05/09 20:50:22     1.1
  +++ docs-book.xml     2001/05/16 14:41:03     1.2
  @@ -16,6 +16,7 @@
     <page id="logicsheet-concepts" label="XSP Logicsheets" 
source="logicsheet-concepts.xml"/>
     <page id="sessions" label="Sessions" source="sessions.xml"/>
   <separator/>
  +  <page id="i18n" label="Internationalization" source="i18n.xml"/>
     <page id="actions" label="Actions" source="actions.xml"/>
     <page id="datasources" label="Using Databases" source="datasources.xml"/>
     <page id="sitemap" label="Sitemap" source="sitemap.xml"/>
  
  
  
  1.2       +1 -0      xml-cocoon2/xdocs/site-book.xml
  
  Index: site-book.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/xdocs/site-book.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- site-book.xml     2001/05/09 20:50:23     1.1
  +++ site-book.xml     2001/05/16 14:41:04     1.2
  @@ -15,6 +15,7 @@
     <page id="logicsheet-concepts" label="XSP Logicsheets" 
source="logicsheet-concepts.xml"/>
     <page id="sessions" label="Sessions" source="sessions.xml"/>
   <separator/>
  +  <page id="i18n" label="Internationalization" source="i18n.xml"/>
     <page id="actions" label="Actions" source="actions.xml"/>
     <page id="datasources" label="Using Databases" source="datasources.xml"/>
     <page id="sitemap" label="Sitemap" source="sitemap.xml"/>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to