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)
|