You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joost Kuif <Jo...@mobillion.nl> on 2006/01/18 10:07:25 UTC

general.field-required translation not working

Hi,

I'm using cforms and trying to override the general.field-required
message for the empty but 'required' (in formdefinition) fields. 
I have the line below in a messages.xml:

<message key="general.field-required">Dit is een verplicht
veld.</message>

For testing purposes: If i specify this key in a label of a field, the
string "Dit is een veplicht veld" is correctly translated for this
field-label. So cocoon is able to find the needed key in my messages.xml
with the keys i specify in the formdefinition. 

Only the translation for required="true" in the <fd:field> tag is NOT
translated into a proper message if a user leaves a (required) field
empty.
 
AFAIK this should be handled somewhere in the forms*.xsl pages.
Unfortunalely i cannot find the problem. Can someone help me? Thanks a
lot!


Joost.


Example:
The code below works, the specified label is overruled by the one in my
messages.xml:

<fd:label>
<i18n:text i18n:key="general.field-required">this should be
overruled</i18n:text>
</fd:label>



The sitemap for my form is:

<map:match pattern="registerform">
  <map:generate type="file" src="pgRegister.xml"/>
  <map:transform type="i18n">
    <map:parameter name="locale" value="nl_NL"/>
  </map:transform>
  <map:transform src="pgRegister.xsl">
  <map:parameter name="css" value="{session-attr:css}" />
  </map:transform>
  <!-- For the field required translation? -->
  <map:transform type="i18n">
    <map:parameter name="locale" value="nl_NL"/>
  </map:transform>
  <map:serialize type="xhtml"/>
</map:match>



The pgRegister.xsl has got some includes (it re-uses components used in
the site):
----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:i18n="http://apache.org/cocoon/i18n/2.1">


                
  <xsl:include
href="blogContext:/xsltVlekken/vkPortal_header_links.xsl"/>
  <xsl:include href="blogContext:/xsltVlekken/vkSiteStatistics.xsl"/>
  <xsl:include href="blogContext:/xsltVlekken/vkTab_menu.xsl"/>
  <xsl:include href="blogContext:/xsltVlekken/vkRegister.xsl"/>

  <xsl:param name="css" select="default.css"/>

<xsl:template match="/pagina">
<html>
  <head>
    <meta name="robots" content="noindex,nofollow"/>
    <xsl:element name="link">
      <xsl:attribute name="type">text/css</xsl:attribute>
      <xsl:attribute name="href">css/<xsl:value-of select="$css"
/></xsl:attribute>
      <xsl:attribute name="rel">stylesheet</xsl:attribute>
    </xsl:element>    
    <title><xsl:value-of select="page_title"/></title>
	<script type="text/javascript"
src="resources/forms/js/forms-lib.js"/>
	<link href="resources/forms/css/forms.css" type="text/css"
rel="stylesheet"/>
	<script type="text/javascript"
src="resources/forms/mattkruse-lib/AnchorPosition.js"/>
	<script type="text/javascript"
src="resources/forms/mattkruse-lib/PopupWindow.js"/>
  </head>
  <body>
    <table border="1" width="100%">
      <tbody>
        <tr>      
          <td colspan="2" align="right">
            <xsl:apply-templates select="vlek_portal_header_links"/>
          </td>
        </tr>
        <tr>        
          <td colspan="2">
            <xsl:apply-templates select="vlek_site_statistics"/>
          </td>                
        </tr>
        <tr>
          <td colspan="2">
            <xsl:apply-templates select="vlek_tab_menu"/>
          </td>
        </tr>
        <tr>
          <td rowspan="4">
            <xsl:apply-templates select="vlek_register"/>
          </td>
        </tr>          
      </tbody>
    </table>
  </body>
</html>
</xsl:template>


</xsl:stylesheet>
------------------------------------------------------------------------
-






The vkRegister.xsl has got the includes to the forms*.xsl's (maybe i'm
missing something here? I tried to add the namespace
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" to the stylesheet, no
result...):

------------------------------------------------------------------------
-
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml">

  <xsl:include
href="resource://org/apache/cocoon/forms/resources/forms-page-styling.xs
l"/>
  <xsl:include
href="resource://org/apache/cocoon/forms/resources/forms-advanced-field-
styling.xsl"/>
  <!-- xsl:include
href="resource://org/apache/cocoon/forms/resources/forms-field-styling.x
sl"/-->

  <xsl:param name="resources-uri">resources</xsl:param>

    <xsl:template match="vlek_register">
      <h3><xsl:value-of select="head/title"/></h3>
      <br/><xsl:value-of select="titletext"/>
      <br/><h3><xsl:value-of select="bodytitle"/></h3>
    <xsl:apply-templates select="body"/>
</xsl:template>


</xsl:stylesheet>

------------------------------------------------------------------------
-


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


Re: general.field-required translation not working

Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2006-01-18 at 07:29 -0700, Jason Johnston wrote:
> Joost Kuif wrote:
> > Hi,
> > 
> > I'm using cforms and trying to override the general.field-required
> > message for the empty but 'required' (in formdefinition) fields. 
> > I have the line below in a messages.xml:
> > 
> > <message key="general.field-required">Dit is een verplicht
> > veld.</message>
> > 
> > For testing purposes: If i specify this key in a label of a field, the
> > string "Dit is een veplicht veld" is correctly translated for this
> > field-label. So cocoon is able to find the needed key in my messages.xml
> > with the keys i specify in the formdefinition. 
> > 
> > Only the translation for required="true" in the <fd:field> tag is NOT
> > translated into a proper message if a user leaves a (required) field
> > empty.
> >  
> > AFAIK this should be handled somewhere in the forms*.xsl pages.
> > Unfortunalely i cannot find the problem. Can someone help me? Thanks a
> > lot!
> > 
> > 
> > Joost.
> > 
> > 
> > Example:
> > The code below works, the specified label is overruled by the one in my
> > messages.xml:
> > 
> > <fd:label>
> > <i18n:text i18n:key="general.field-required">this should be
> > overruled</i18n:text>
> > </fd:label>
> 
> 
> The i18n elements produced by CForms all have an attribute 
> i18n:catalogue="forms", which means that the i18n transformer will 
> always look for a catalogue configured with the id "forms" to get its 
> translations for these elements.  The example above works because you're 
> not telling it to use a specific catalogue, so it uses whichever default 
> catalogue you have configured in your sitemap.
> 
> You need to have something like this in your sitemap:
> 
> <map:transformer name="i18n" 
> src="org.apache.cocoon.transformation.I18nTransformer">
>     <catalogues default="default">
>        <catalogue id="forms" name="Messages" location="path/to/forms"/>
>        <catalogue id="default" name="Messages" location="path/to/i18n"/>
>     </catalogues>
> </map:transformer>
> 
> And make sure your overridden CForms messages are in the "forms" 
> catalogue.  See the I18nTransformer docs for more details about setting 
> up catalogues.

More specifically,  it is also possible to avoid duplicating the entire
forms catalogue by having a config like this:

<map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
    <catalogues default="default">
       <catalogue id="forms" name="messages">
         <location>path/to/custom-i18n</location>
         <location>resource://org/apache/cocoon/forms/system/i18n</location>
       </catalogue>
       <catalogue id="default" name="Messages" location="path/to/i18n"/>
    </catalogues>
</map:transformer>

The path/to/custom-i18n directory would contain a file called
messages(_lang).xml in which you only need to redefine the messages you
want to change.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: general.field-required translation not working

Posted by Jason Johnston <co...@lojjic.net>.
Joost Kuif wrote:
> Hi,
> 
> I'm using cforms and trying to override the general.field-required
> message for the empty but 'required' (in formdefinition) fields. 
> I have the line below in a messages.xml:
> 
> <message key="general.field-required">Dit is een verplicht
> veld.</message>
> 
> For testing purposes: If i specify this key in a label of a field, the
> string "Dit is een veplicht veld" is correctly translated for this
> field-label. So cocoon is able to find the needed key in my messages.xml
> with the keys i specify in the formdefinition. 
> 
> Only the translation for required="true" in the <fd:field> tag is NOT
> translated into a proper message if a user leaves a (required) field
> empty.
>  
> AFAIK this should be handled somewhere in the forms*.xsl pages.
> Unfortunalely i cannot find the problem. Can someone help me? Thanks a
> lot!
> 
> 
> Joost.
> 
> 
> Example:
> The code below works, the specified label is overruled by the one in my
> messages.xml:
> 
> <fd:label>
> <i18n:text i18n:key="general.field-required">this should be
> overruled</i18n:text>
> </fd:label>


The i18n elements produced by CForms all have an attribute 
i18n:catalogue="forms", which means that the i18n transformer will 
always look for a catalogue configured with the id "forms" to get its 
translations for these elements.  The example above works because you're 
not telling it to use a specific catalogue, so it uses whichever default 
catalogue you have configured in your sitemap.

You need to have something like this in your sitemap:

<map:transformer name="i18n" 
src="org.apache.cocoon.transformation.I18nTransformer">
    <catalogues default="default">
       <catalogue id="forms" name="Messages" location="path/to/forms"/>
       <catalogue id="default" name="Messages" location="path/to/i18n"/>
    </catalogues>
</map:transformer>

And make sure your overridden CForms messages are in the "forms" 
catalogue.  See the I18nTransformer docs for more details about setting 
up catalogues.

Hope that helps
--Jason

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