Hi list,

I first tried to introduce directly the <i18n:text> in the document like this
      <p>  <i18n:text>Seach</i18n:text></p>

The result is

Internal Server Error
Message: null
Description: No details available.
Sender: org.apache.cocoon.servlet.CocoonServlet
Source: Cocoon Servlet
Request URI
evolution/indexi.html
cause
The prefix "i18n" for element "i18n:text" is not bound.
request-uri
/evolution/indexi.html
Apache Cocoon 2.2.0-dev

Then I realised that the modification of the browser language tranlate the tabs and the menu.
So I try to go on with this method.

I like the idea to separate text from non text.
I did'nt use svg files. May be it interresting too.
In my  exemple  we only modify indexi.xml to replace an image.
If we had one file for each language (index_en.xml,index_de.xml  ,index_se.xml) we should modify each file.
In general we can keep the layout, and just change the text.

I know  there are two other possibilities than the browser lang to indicate the language.
index.en.xml, index.de.xml , index.se.xml
index.xml?lang=en, index.xml?lang=de, index.xml?lang=se,

In those cases the sitemap.xmap should analyse the parameters and the suffixs to dectect the language.
The sitemap.xmap should delclare a priority the resolve conflicts.
Example langformatpriority=langparameter, browserlang,filesuffixlang

My first idea was to have a separate first "treatment" to translate the source text everywhere:
 -in "boxes" organized in the general layout given by the skin (header, tabs, menu, footer)
- in "boxes" organized in layout inside the page.
But then I follow the sitemap.xmap and I modify as little as possible.

Why did you switch the order and nested the map:select?
I switch the order so that the pfd suits the browser lang value. But eventhought,
I had a still a problem with the pdf display. At the beginning,  it suits the browser lang value.
Then it sticks to one lang.
I don't know yet, if it a server cache problem or a mistake from my implementation.

May be the following version with the "dispatcher" will simplifiy the way to have the same display.  


Paul




Thorsten Scherler <thorsten@apache.org>

28/02/2006 19:49
Please respond to user

       
        To:        forrest dev <dev@forrest.apache.org>
        cc:        forrest user <user@forrest.apache.org>
        Subject:        Re: forrest 0.7 multi language site contribution and question        (second version)



El lun, 27-02-2006 a las 08:34 +0100, Paul.Divine@alcatel.fr escribió:
>
> Hi list,
> May be this mail should be send to a dev list.

:)

This discussion will go on on dev. ;)

This is a really nice mail, thank you very much for this infos.

...the only thing that I wonder is whether we can simplify the
process. ;)

>
>
> In order to display with dynamic forrest (started with forrest run)
> a page with a text corresponding to the language of the preference  
> of the browser of the user, I did the following modifications.
> This only concerns the page, not the menu or the tabs.
> The basic idea is to  
> - created a new DTD for document to introduce an element tt which
> surround the text to be translated.

Why did you not decided to use xml:lang?
http://www.w3.org/TR/REC-xml/#sec-lang-tag


> - to translate this tt element to an i18:text element with an xslt
> stylesheet
> - apply the i18n transformation to translate.

Why did you not directly used
http://cocoon.apache.org/2.1/userdocs/i18nTransformer.html
<para title="first" name="article"  i18n:attr="title name">
 <i18n:text>This text will be translated.</i18n:text>
</para>

> Note  
> In the examples  
> forrest is      in D:\DATA\apache\apache-forrest-0.7
> forrest site is in D:\DATA\apache\apache-forrest-0.7-paul-site
>
> A) I create a new DTD document-v21.dtd with a new module
> document-v21.mod
> in directory
> D:\DATA\apache\apache-forrest-0.7\main\webapp\resources\schema\dtd\
>
> The document-v21.dtd is
>
> <!ENTITY % common-charents PUBLIC
>     "-//APACHE//ENTITIES Common Character Entity Sets V1.0//EN"
>     "common-charents-v10.mod">
> %common-charents;
>
> <!-- =============================================================== > -->
> <!-- Document -->
> <!-- =============================================================== > -->
>
> <!ENTITY % document PUBLIC
>     "-//APACHE//ENTITIES Documentation V2.1//EN"
>     "document-v21.mod">
> %document;
>
>
> Note  
> Only the two lines are different from document-v20.dtd
>     "-//APACHE//ENTITIES Documentation V2.1//EN"
>     "document-v21.mod">
>
>
> in directory
> D:\DATA\apache\apache-forrest-0.7\main\webapp\resources\schema\dtd\
> The document document-v21.mod is a copy of document-v20.mod  
> with differences given hereafter
>
> 1) The line  
> <!ENTITY % text "#PCDATA">
> becomes
> <!-- <!ENTITY % text "#PCDATA"> -->
> This line is put in comment
>
> 2) The folowing lines are added after
> <!ENTITY % simpletext "#PCDATA">
> <!ENTITY % text "simpletext|tt">
>
> 3) before the lines
> <!-- ==================================================== -->
> <!-- Body -->
> <!-- ==================================================== -->
>
> add  
>
> <!--   tt text to translate -->
> <!ELEMENT tt (%simpletext;)>
>
>
>
>
> The basic idea is to surround text to be translated with the tt
> element.
>
>
> B) A new stylesheet i18ntext.xsl to replace <tt> by <i18n:text>
> in directory D:\DATA\apache\apache-forrest-0.7\main\webapp\resources
> \stylesheets
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                 xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
>
>   <xsl:import href="copyover.xsl"/>
>   <xsl:template match="tt">
>      <i18n:text>
>      <xsl:apply-templates select="@*"/>
>      <xsl:apply-templates />
>      </i18n:text>
>   </xsl:template>
> </xsl:stylesheet>
>

see above, why did you not directly declared i18n:text in the dtd and
used tt?

> C) Modify the sitemap.xmap in order to do the two modifications  
>    (markup modification and translation) for html page and pdf page
> in directory  
> D:\DATA\apache\apache-forrest-0.7\main\webapp
>
> After the lines  
>       <map:match pattern="**body-*.html">
>         <map:generate src="cocoon:/{1}{2}.xml"/>
>         <map:transform type="idgen"/>
>         <map:transform type="xinclude"/>
>
> Add the lines
>  <!-- paul begin -->        
>         <map:select type="config">
>           <map:parameter name="value" value="{defaults:i18n}"/>
>           <map:when test="true">
>             <map:transform src="{forrest:stylesheets}/i18ntext.xsl"/>
>        
>             <map:transform type="i18n">
>               <map:parameter name="locale" value="{request:locale}"/>
>             </map:transform>
>             </map:when>
>         </map:select>
> <!-- paul end -->          
>
> and after the lines
>       <map:match type="regexp" pattern="^(.*?)([^/]*).fo$">
>         <map:select type="exists">
>           <map:when test="{project:content.xdocs}{1}{2}.fo">
>             <map:generate src="{project:content.xdocs}{1}{2}.fo"/>
>           </map:when>
>           <map:otherwise>
>             <map:aggregate element="site">
>               <map:part src="cocoon:/skinconf.xml"/>
>               <map:part src="cocoon:/{1}{2}.xml"/>
>             </map:aggregate>
>             <!-- <map:transform type="idgen"/> -->
>             <map:transform type="xinclude"/>
>
> add the lines
> <!-- paul begin -->        
>         <map:select type="config">
>           <map:parameter name="value" value="{defaults:i18n}"/>
>           <map:when test="true">
>             <map:transform src="{forrest:stylesheets}/i18ntext.xsl"/>
>        
>             <map:transform type="i18n">
>               <map:parameter name="locale" value="{request:locale}"/>
>             </map:transform>
>                 </map:when>
>         </map:select>
> <!-- paul end -->    

Why did you decide to use inline translations over document specific.
Like:
index_en.xml; index_de.xml; index_es.xml; ...

> D) in the pdf plugin  output.xmap we inverse the presence test  
> to solve a problem of cache (this is a workaround)
> (the cache does not recognise that the language has changed, so it
> displays the same page)
> in the directory
> D:\DATA\apache\apache-forrest-0.7\build\plugins
> \org.apache.forrest.plugin.output.pdf\
>
> After the lines
>   <map:pipelines>
>     <map:pipeline>
>       <!-- generate .pdf files from .fo -->
>       <map:match type="regexp" pattern="^(.*?)([^/]*).pdf$">
>         <map:select type="exists">
> put in comment the lines
> <!-- >           <map:when test="{project:content.xdocs}/{1}{2}.pdf">
>             <map:read src="{project:content.xdocs}/{1}{2}.pdf"/>
>           </map:when>
>           <map:otherwise>
>             <map:generate src="cocoon://{1}{2}.fo"/>
>             <map:serialize type="fo2pdf"/>
>           </map:otherwise>
> -->
> and after add the lines
> <!-- paul begin -->
>           <map:when test="{project:content.xdocs}/{1}{2}.xml">
>             <map:generate src="cocoon://{1}{2}.fo"/>
>             <map:serialize type="fo2pdf"/>
>           </map:when>
>           <map:otherwise>
>             <map:select type="exists">
>               <map:when test="{project:content.xdocs}/{1}{2}.pdf">
>                 <map:read src="{project:content.xdocs}/{1}{2}.pdf"/>
>               </map:when>          
>             </map:select>
>           </map:otherwise>
> <!-- paul end   -->


Why did you switch the order and nested the map:select?

> E) In forrest.xmap in D:\DATA\apache\apache-forrest-0.7\main\webapp
> In order to catch the new DTD.
> After the lines      
>         <sourcetype name="document-v20">
>           <document-declaration public-id="-//APACHE//DTD
> Documentation V2.0//EN" />
>         </sourcetype>
> Add the lines
> <!-- add paul begin -->
>         <sourcetype name="document-v21">
>           <document-declaration public-id="-//APACHE//DTD
> Documentation V2.1//EN" />
>         </sourcetype>
> <!-- add paul end -->
>          
> Afer the lines
>           <map:when test="document-v20">
>             <map:transform
> src="{forrest:stylesheets}/docv20todocv13.xsl" />
>           </map:when>
> Add the lines
> <!-- add paul begin -->
>           <map:when test="document-v21">
>             <map:transform
> src="{forrest:stylesheets}/docv20todocv13.xsl" />
>           </map:when>
> <!-- add paul end -->
>
> F) in D:\DATA\apache\apache-forrest-0.7\main\webapp\skins\common
> \translations
> fill catalogs CommonMessages_xx.xml with in the languages you want.
> For the example  
> I use CommonMessages_en_US.xml and CommonMessages_fr.xml
> with already translated "Search".
>   <message key="Search">Rechercher</message>
>
> G) Update Catalog of forrest
> In D:\DATA\apache\apache-forrest-0.7\main\webapp\resources\schema
> \catalog.forrest
> After the line
> -- Document Type Definitions --
>
> add the line
> PUBLIC "-//APACHE//DTD Documentation V2.1//EN"
>        "dtd/document-v21.dtd"
>
>
> H)in catalog.forrest.xcat in the directory
> D:\DATA\apache\apache-forrest-0.7\main\webapp\resources\schema
> After the line
> <!-- Document Type Definitions (current) -->
>
> add the lines
> <!-- paul begin -->
> <public publicId="-//APACHE//DTD Documentation V2.1//EN"
>         uri="dtd/document-v21.dtd"/>
> <!-- paul end -->
>
> After the line
> <!-- Reusable modules -->
> add the lines
>
> <!-- paul begin -->
> <public publicId="-//APACHE//ENTITIES Documentation V2.1//EN"
>         uri="dtd/document-v21.mod"/>
> <!-- paul  end  -->
>
>
> I) Put in your page the new DOCTYPE and the text to translate in <tt>
> markup.
> Exemple indexi.xml  
> in the directory
> D:\DATA\apache\apache-forrest-0.7-paul-site\src\documentation\content
> \xdocs
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.1//EN"
> "http://forrest.apache.org/dtd/document-v21.dtd">
> <document>  
>   <header>  
>     <title><tt>Search</tt> untranslate</title>  
>   </header>  
>   <body>  
>     <section id="overview">
>       <title><tt>Search</tt>  untranslate</title>
>       <p><tt>Search</tt>  untranslate
>      </p>
>     </section>
>   </body>
> </document>
>
>
>
> J) In forrest.properties of the site put the indicator to true
> Example  
> D:\DATA\apache\apache-forrest-0.7-paul-site
> After the line
> #project.i18n=true
> add the line  
> project.i18n=true
>
> K) In the directory of your site start the site with command "forrest
> run"
>
> Example
> cd D:\DATA\apache\apache-forrest-0.7-paul-site
> SET JAVA_HOME=C:\java\j2sdk1.4.2_03
> set FOREST_HOME=C:\apache\apache-forrest-0.7
> set PATH=%PATH%;%FOREST_HOME%\bin
> forrest run
>
> L) To look at the results  
>
> - With your favorit browser put your language preferences to
> english  en_US  
> (tool/internet option/language ..)
>
> http://localhost:8888/indexi.html
> You can see "Search"
> and if you clic on the PDF icon you should see the same in pdf
> format.
>
> - With your favorit browser put your language preferences to german
> de
>
> http://localhost:8888/indexi.html
> You can see "Suche"
> and if you clic on the PDF icon you should see the same in pdf
> format.
>
> - With your favorit browser put your language preferences to french
> fr
>
> http://localhost:8888/indexi.html
> You can see "Rechercher"
> and if you clic on the PDF icon you should see the same in pdf
> format.
>
>
> Note
> For the tab and the menu  
> Catalogues of the language should be define
> D:\DATA\apache\apache-forrest-0.7-paul-site\src\documentation
> \translations
> langcode.xml
>
> menu_de.xml menu_fr.xml the menu_lang file should exist
>
> Restrictions
>  - The research function in the site is looking at the text in the
> page
>    Only the basic langague is seen, not the translations. Some work
> is  
>    needed to add to the index the text of each language.  

Yeah, that would be easier if we use index_en.xml,...

>  - The other tags of i18n like "if" are not taken into account.

yeah, why not using i18n:text right away?

>  - To inform the user of the multi language possibilities  
>    a new skin should be done.

yeah, right, but I think we should rather extend the dispatcher
(implementing/testing i18n is next on my list). It is very easy with jx
in the structurer to responding/requesting index_en.xml; index_de.xml;
index_es.xml; ...

>  - Only document-v20.dtd can be translated all the other formats
> cannot.

Hmm.

>
> The question is: Why the Pdf function has no translation?

I do not understand this question.

salu2
--
thorsten

"Together we stand, divided we fall!"
Hey you (Pink Floyd)