You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sylvain Wallez <sy...@apache.org> on 2006/01/15 10:41:37 UTC

Re: CForms, double-listbox and i18n.

Steinar Jonsson wrote:
> Hi
>
> I have a little i18n problem in 2.1.8:
>
> A form contains a double-listbox that I insert string values into 
> from javaflow. 
>
> Some value strings have content that I want the i18n transformer 
> to translate. If I just add i18n tags to the strings they are not 
> transformed. 
>
> What is the correct way to do this?
>   

You say you're "inserting string values into" the selection-list. What 
implementation of selection-list do you use?

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://bluxte.net                     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


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


Re: CForms, double-listbox and i18n.

Posted by Steinar Jonsson <sj...@online.no>.
On Sunday 15 January 2006 23:05, Jason Johnston wrote:
> Steinar Jonsson wrote:
> >>>        SelectableWidget widget =
> >>>(SelectableWidget)form.getChild(widgetName);
> >>>widget.setSelectionList(listOfLabelAndValuePairs, "value", "label");
> >>
> >>I believe that if the value of the "label" path is a
> >>org.apache.cocoon.forms.util.I18nMessage (see the javadocs) then it will
> >>write out the label surrounded by the appropriate i18n tags.
> >
> > I may be wrong, but I somehow got the impression that would only work
> > if the entire label text is an i18n key. In my case each label typically
> > has a prefix part that should be translated and a name part that should
> > not.
>
> You are correct for basic form of I18nMessage.  However it also provides
> special constructors for passing parameters.  So you could pass the
> parts that shouldn't be translated as parameters which would get
> substituted into the final string.
>
> String[] params = {"Jason", "Steinar"};
> I18nMessage msg = new I18nMessage("Message_Key", params);
>
> <message key="Message_Key">{0} hopes this helps {1}.</message>
>

Yes! That looks like exactly what I need! Many thanks!

Steinar, busy writing "read the docs" a hundred times


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


Re: CForms, double-listbox and i18n.

Posted by Jason Johnston <co...@lojjic.net>.
Steinar Jonsson wrote:
>>>        SelectableWidget widget =
>>>(SelectableWidget)form.getChild(widgetName);
>>>widget.setSelectionList(listOfLabelAndValuePairs, "value", "label");
>>
>>I believe that if the value of the "label" path is a
>>org.apache.cocoon.forms.util.I18nMessage (see the javadocs) then it will
>>write out the label surrounded by the appropriate i18n tags.
> 
> 
> I may be wrong, but I somehow got the impression that would only work 
> if the entire label text is an i18n key. In my case each label typically has 
> a prefix part that should be translated and a name part that should not.

You are correct for basic form of I18nMessage.  However it also provides 
special constructors for passing parameters.  So you could pass the 
parts that shouldn't be translated as parameters which would get 
substituted into the final string.

String[] params = {"Jason", "Steinar"};
I18nMessage msg = new I18nMessage("Message_Key", params);

<message key="Message_Key">{0} hopes this helps {1}.</message>

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


Re: CForms, double-listbox and i18n.

Posted by Steinar Jonsson <sj...@online.no>.
On Sunday 15 January 2006 21:18, Jason Johnston wrote:
> Steinar Jonsson wrote:
> > On Sunday 15 January 2006 10:41, Sylvain Wallez wrote:
> >>Steinar Jonsson wrote:
> >>>Hi
> >>>
> >>>I have a little i18n problem in 2.1.8:
> >>>
> >>>A form contains a double-listbox that I insert string values into
> >>>from javaflow.
> >>>
> >>>Some value strings have content that I want the i18n transformer
> >>>to translate. If I just add i18n tags to the strings they are not
> >>>transformed.
> >>>
> >>>What is the correct way to do this?
> >>
> >>You say you're "inserting string values into" the selection-list. What
> >>implementation of selection-list do you use?
> >
> > First, it's not a double-listbox as I wrote above, I had another problem
> > in my head at the same time and they got mixed up, sorry. (Though I
> > suspect listbox or double-listbox makes no difference in this case)
> >
> > Here's what I do in the java class :
> >
> > import org.apache.cocoon.forms.formmodel.SelectableWidget;
> > ....
> >         SelectableWidget widget =
> > (SelectableWidget)form.getChild(widgetName);
> > widget.setSelectionList(listOfLabelAndValuePairs, "value", "label");
>
> I believe that if the value of the "label" path is a
> org.apache.cocoon.forms.util.I18nMessage (see the javadocs) then it will
> write out the label surrounded by the appropriate i18n tags.

I may be wrong, but I somehow got the impression that would only work 
if the entire label text is an i18n key. In my case each label typically has 
a prefix part that should be translated and a name part that should not.

>
> Another solution would be to create a SelectionList object (again, see
> the javadocs... some SelectionList implementations allow i18n-ized
> labels) and use the SelectableWidget.setSelectionList(SelectionList s)
> method.
>

Thanks, I will look into that.

Steinar


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


Re: CForms, double-listbox and i18n.

Posted by Jason Johnston <co...@lojjic.net>.
Steinar Jonsson wrote:
> On Sunday 15 January 2006 10:41, Sylvain Wallez wrote:
> 
>>Steinar Jonsson wrote:
>>
>>>Hi
>>>
>>>I have a little i18n problem in 2.1.8:
>>>
>>>A form contains a double-listbox that I insert string values into
>>>from javaflow.
>>>
>>>Some value strings have content that I want the i18n transformer
>>>to translate. If I just add i18n tags to the strings they are not
>>>transformed.
>>>
>>>What is the correct way to do this?
>>
>>You say you're "inserting string values into" the selection-list. What
>>implementation of selection-list do you use?
>>
> 
> 
> First, it's not a double-listbox as I wrote above, I had another problem 
> in my head at the same time and they got mixed up, sorry. (Though I 
> suspect listbox or double-listbox makes no difference in this case)
> 
> Here's what I do in the java class :
> 
> import org.apache.cocoon.forms.formmodel.SelectableWidget;
> ....
>         SelectableWidget widget = (SelectableWidget)form.getChild(widgetName);
>         widget.setSelectionList(listOfLabelAndValuePairs, "value", "label");
> 

I believe that if the value of the "label" path is a
org.apache.cocoon.forms.util.I18nMessage (see the javadocs) then it will 
write out the label surrounded by the appropriate i18n tags.

Another solution would be to create a SelectionList object (again, see 
the javadocs... some SelectionList implementations allow i18n-ized 
labels) and use the SelectableWidget.setSelectionList(SelectionList s) 
method.

> Form definition contains :
>     <fd:field id="accesses">
>       <fd:label></fd:label>
>       <fd:datatype base="string"/>
>       <fd:selection-list/>
>     </fd:field>
> 
> and template :
>               <ft:widget id="accesses">
>                 <fi:styling list-type="listbox" listbox-size="23">
>                 </fi:styling>
>               </ft:widget>
> 
> display pipeline looks like this:
>         <map:generate 
>             src="pages/cform/{request-param:pagename}/{request-param:pagename}-template.xml"/>
>         <map:transform type="forms"/>
>         <map:transform type="i18n">
>           <map:parameter name="locale" value="{global:locale}"/>
>         </map:transform>
>         <map:serialize type="xml"/>
> 
> and is aggregated into:
>         <map:transform src="layouts/default/xsl/layout.xsl">
>           <map:parameter name="template" value="../xml/layout.xml"/>
>         </map:transform>
>         <map:transform src="styles/{request-param:style}/xsl/forms-samples-styling.xsl"/>
>         <map:transform type="i18n">
>           <map:parameter name="locale" value="{global:locale}"/>
>         </map:transform>
>         <map:serialize/>
> 
> My "forms-samples-styling.xsl" is basically a copy of the one supplied with cocoon.
> 
> Does this make sense?
> 
> Steinar
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Re: CForms, double-listbox and i18n.

Posted by Steinar Jonsson <sj...@online.no>.
On Sunday 15 January 2006 10:41, Sylvain Wallez wrote:
> Steinar Jonsson wrote:
> > Hi
> >
> > I have a little i18n problem in 2.1.8:
> >
> > A form contains a double-listbox that I insert string values into
> > from javaflow.
> >
> > Some value strings have content that I want the i18n transformer
> > to translate. If I just add i18n tags to the strings they are not
> > transformed.
> >
> > What is the correct way to do this?
>
> You say you're "inserting string values into" the selection-list. What
> implementation of selection-list do you use?
>

First, it's not a double-listbox as I wrote above, I had another problem 
in my head at the same time and they got mixed up, sorry. (Though I 
suspect listbox or double-listbox makes no difference in this case)

Here's what I do in the java class :

import org.apache.cocoon.forms.formmodel.SelectableWidget;
....
        SelectableWidget widget = (SelectableWidget)form.getChild(widgetName);
        widget.setSelectionList(listOfLabelAndValuePairs, "value", "label");

Form definition contains :
    <fd:field id="accesses">
      <fd:label></fd:label>
      <fd:datatype base="string"/>
      <fd:selection-list/>
    </fd:field>

and template :
              <ft:widget id="accesses">
                <fi:styling list-type="listbox" listbox-size="23">
                </fi:styling>
              </ft:widget>

display pipeline looks like this:
        <map:generate 
            src="pages/cform/{request-param:pagename}/{request-param:pagename}-template.xml"/>
        <map:transform type="forms"/>
        <map:transform type="i18n">
          <map:parameter name="locale" value="{global:locale}"/>
        </map:transform>
        <map:serialize type="xml"/>

and is aggregated into:
        <map:transform src="layouts/default/xsl/layout.xsl">
          <map:parameter name="template" value="../xml/layout.xml"/>
        </map:transform>
        <map:transform src="styles/{request-param:style}/xsl/forms-samples-styling.xsl"/>
        <map:transform type="i18n">
          <map:parameter name="locale" value="{global:locale}"/>
        </map:transform>
        <map:serialize/>

My "forms-samples-styling.xsl" is basically a copy of the one supplied with cocoon.

Does this make sense?

Steinar


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