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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]