cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Koschnick <ar...@gmx.net>
Subject i18n:text stored in an xsl:variable
Date Thu, 20 Mar 2008 17:29:51 GMT
Hello,

I have a problem with the i18n block (cocoon 2.1.11 release).

It seems that the results of a <i18n:text/> translation cannot be stored 
in a <xsl:variable/>.

What I'm trying to do is to show an error message with localizable 
parameters.

Passed XML:

<paramText param0="DATE">ERROR_FILTER</paramText>

messages.xml:

<message key="ERROR_FILTER">Error while evaluating filter, please check 
the syntax of {0}.</message>
<message key="DATE">Date Scheduled</message>

So my XSL looks something like this:

<xsl:template match="paramText">
     <xsl:variable name="param0">
         <i18n:text key="{@param0}"/>
     </xsl:variable>
     <span>
         <i18n:translate>
             <i18n:text key="{text()}" />
                 <i18n:param>
                     <xsl:value-of select="$param0" />
                 </i18n:param>
             </i18n:text>
         </i18n:translate>
     </span>
</xsl:template>

But in the output $param0 is not shown (since it's empty).  If I change 
the variable to:

<xsl:variable name="param0">
     <i18n:text>
         <xsl:value-of select="@param0"/>
     </i18n:text>
</xsl:variable>

it contains the untranslated text (value of @param0 -> DATE).

If I change the <i18n:translate/> block to:

<i18n:translate>
     <i18n:text key="{text()}" />
         <i18n:param>
             <i18n:text key="{@param0}"/>
         </i18n:param>
     </i18n:translate>
</i18n:translate>

the output will _only_ consist of @param0 ("Date Scheduled") and not the 
message text.

So how would I go about implementing the error display?

I wouldn't know of any way of getting access to the i18n message 
resources from within Java either, otherwise I would do the translation
in my code.

Thanks,
Rainer

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


Mime
View raw message