cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves Zoundi <bibl...@hermes.ulaval.ca>
Subject RE: [FIX] I18nTransformer [CACHING PIPELINE]
Date Tue, 12 Sep 2006 00:40:28 GMT
Hi everybody,

   There is really a bug with the i18ntransformer! If you thing I'm doing
something wrong with the code below please help!

My test scenario
-----------------------------
   I used an unmodified build of cocoon, no custom exclusions of some
blocs. I checked again my code based on the samples : copy and paste.
Guess wwhat? It doesn't work! I am pretty sure about my code, nothing
special straight from the samples. 
   I modified the welcome.xml file to include some i18n:text and I created
a test.html file with some i18n keys. I used the configuration from the
i18n samples and I believe there is a bug with the i18ntransformer. 
   I only used the root sitemap.xmap.

* Here are the relevant parts of the sitemap.xmap
...
 <map:transformer name="i18n" logger="sitemap.transformer.i18n"
src="org.apache.cocoon.transformation.I18nTransformer">
 <catalogues default="messages">
   <catalogue id="messages" name="messages" location="translations"/>
          <catalogue id="menu" name="menu" location="translations"/>
          <catalogue id="tiered" name="messages">
        <location>translations/tiered</location>
        <location>translations</location>
      </catalogue>
 </catalogues>
        <cache-at-startup>true</cache-at-startup>
 </map:transformer>
...
 <map:action name="locale" logger="sitemap.action.locale"
src="org.apache.cocoon.acting.LocaleAction">
        <!-- Creates a new session if needed. Used with 'store-in-session'
param -->
        <create-session>true</create-session>
        <!-- Stores locale information in session. A session should be
created before, 
             otherwise 'create-session' should be true.
                -->
        <store-in-session>true</store-in-session>
        <!-- Stores locale information in request attributes -->
        <store-in-request>true</store-in-request>
        <!-- Stores locale information in a client cookie -->
        <store-in-cookie>false</store-in-cookie>
      <default-locale language="en" country="US"/>
 </map:action>

...
 <!-- main pipeline -->
  <map:pipeline type = "caching">
   <map:act type = "locale">    
    <map:match pattern = "index.html">
	<map:redirect-to uri = ""/>
    </map:match> 
    <map:match pattern = "status.html">
       <map:generate type = "status"/>
       <map:transform src = "stylesheets/system/status2html.xslt"/>
       <map:serialize type = "html"/>    
    </map:match>    
    <map:match pattern = "test.html">
	<map:generate src = "test.html"/>
	 <map:transform type = "i18n">
	 <map:parameter name="locale" value="{../locale}"/>
      </map:transform>
      <map:serialize type = "html"/>
    </map:match> 
    <!-- welcome page -->
    <map:match pattern="">
      <map:generate src="welcome.xml"/>      
      <map:transform type = "i18n">		 
	 <map:parameter name="locale" value="{../locale}"/>
      </map:transform>
      <map:transform src="welcome.xslt">
        <map:parameter name="contextPath" value="{request:contextPath}"/>
      </map:transform>
      <map:serialize type="xhtml"/>
    </map:match>
</map:act>
...

...

Here are the original welcome.xml(customized) and test.html files
*welcome.xml
<?xml version="1.0" encoding="UTF-8"?><!--
<welcome xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
 <message>
 <p><i18n:text>francais</i18n:text></p>
 <p><i18n:text>anglais</i18n:text></p>
 <p><a href = "test.html">test</a></p>
   Congratulations! If you are reading this page, it means that
   your Apache Cocoon installation was successful.
 </message>
  <message id="samples">
   To know more about Cocoon capabilities, look at the <link
href="samples/">samples</link>
  </message>  
</welcome>

* test.html
<html xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
 
	<head><title>test</title></head>
	<body>
	<p><i18n:text>francais</i18n:text></p>
 <p><i18n:text>anglais</i18n:text></p>
 <p><a href = "index.html">home</a></p>
	
	</body>
</html>

* messages_en_US.xml
<catalogue xml:lang="en_US">
 <message key="anglais">english</message>
 <message key="francais">french</message>  
</catalogue>

* messages_fr_FR.xml
<catalogue xml:lang="fr_FR">
 <message key="anglais">anglais</message>
 <message key="francais">francais</message>  
</catalogue>

* messages.xml
<catalogue xml:lang="fr_FR">
 <message key="anglais">anglais</message>
 <message key="francais">francais</message>  
</catalogue>

The catalogs are simple with only 2 keys.

I am switching the languages by manually appending a request parameter
?locale=fr_FR or ?locale=en_US to the current URL. Sometimes when I
navigate between index.html and test.html, I see that the locale is not
updated, Cocoon is serving the cache without analysing the session locale.
I tried using the session-attribute generator to see if the locale was
updated and It is. The cocoon status shows me that the catalog are in the
cache and the cache keys of the pages(i18ntransformer cache keys) seem all
right. The keys seem unique for a request.

Thanks in advance.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message