cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Piroumian <kpiroum...@apache.org>
Subject Re: problems with i18n transformer in cocoon 2.0.2 - is this a bug?
Date Wed, 29 May 2002 11:37:45 GMT
problems with i18n transformer in cocoon 2.0.2 - is this a bug?I've just
checked the source from the 2.0.3 branch from CVS and the correct line is
already there:
                StringBuffer pathToChild = new
StringBuffer(pathToParent).append('/').append(child.getNodeName());

Couldn't find in logs if it was incorrect before the 2.0.2 version, but
there is no differences in that line between 2.0.2 and 2.0.3.

I've also checked i18n sample with 'cache-at-startup' option and it also
works fine (2.1-dev version). As there is no difference in 2.0.3 and 2.1
versions of XMLResourceBundle then something's wrong at your site.

Regards,
  Konstantin


----- Original Message -----
From: Brian Buckley
To: cocoon-users@xml.apache.org
Sent: Wednesday, May 29, 2002 2:20 PM
Subject: problems with i18n transformer in cocoon 2.0.2 - is this a bug?


cocoon version: 2.0.2
servlet engine: tomcat 4.0.3
OS: windows 2000
JDK: 1.4.0
I am trying to add internationalisation to my site by using i18n.  After a
day fruitlessly trying to figure out where I am going wrong I added some
debug printlns to the I18nTransformer source.  My setup is as follows:
******************** sitemap: ***************
<map:transformer name="i18n"
src="org.apache.cocoon.transformation.I18nTransformer">
        <catalogue-name>messages</catalogue-name>
        <catalogue-location>translations</catalogue-location>
        <cache-at-startup>true</cache-at-startup>       <----- I added this
to make debugging easier as the cache is a simple hash table
</map:transformer>
     .
     .
<map:match pattern="login">
   <map:act type="locale"/>
    <map:aggregate element="page" label="raw-xml">
        <map:part src="cocoon:/login.banner" />
         <map:part src="cocoon:/login.xml" />
    </map:aggregate>
    <map:transform type="i18n" label="trans-xml"/>
    <map:transform src="stylesheets/page2html.xsl" />
    <map:serialize />
</map:match>
******************* dictionary: **************
in $TOMCAT_HOME/webapps/myapp/translations
   /messages.xml
   /messages_en.xml
   /...etc,etc
******************* messages contain: *****
<catalogue xml:lang="en">
        <message key="login.redirect">Go to Secure Login</message>
        <message key="login.welcome">Welcome</message>
             ... etc, etc
</catalogue>
****************** xsp: **********************
<title name="login.welcome" i18n:attr="name"/>
<input type="submit"><i18n:text>login.redirect</i18n:text></input>
Now.  At the browser I am getting the 'login.welcome' and 'login.redirect'
keys untranslated.  My debug statements showed that the string passed into
XMLResourceBundle.getString(String key) was
"/catalogue/message[@key='login.welcome']", but the XMLResourceBundle cache
contained the key "/message[@key='login.welcome']".  Clearly a mismatch. So
I looked at the code:
I18nTransformer.getString() method prepends the key to be passed to the
XMLResourceBundle.getString() with I18N_CATALOGUE_PREFIX.
I18N_CATALOGUE_PREFIX is the string constant "/catalogue/message".
XMLResourceBundle.cacheAll(Node parent, String pathToParent) is initially
entered with a pathToParent of "" from init().  The pathToChild StringBuffer
takes this as the initial buffer value in the line:
StringBuffer pathToChild = new
StringBuffer(pathToParent).append(child.getNodeName());
If I change the initial call to cacheAll with a pathToParent of "/", and
change the above line to
StringBuffer pathToChild = new
StringBuffer(pathToParent).append(parent.getNodeName()).append('/').append(c
hild.getNodeName());
I reproduce the expected key in the cache hashtable, and everything works.
Is this a bug in cocoon 2.0.2 or is there an alternative solution to this
without changing cocoon source code?
Thanks,
Brian Buckley.

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


Mime
View raw message