cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject i18n questions
Date Fri, 09 Apr 2004 10:36:29 GMT
Hi All

I use i18n a lot with Woody and Flowscript. I prefer to keep all user 
message strings out of woody files and flowscripts, regardless of 
whether the project needs translating to another language.

  I have a couple of situations where I have not worked out how to use 
i18n effectively. Both are related to dynamic selectionlists. Are there 
solutions for these?

1. We need to internationalise custom fail messages. Placing i18n tags 
inside do not result in their being looked up. We cannot use Woody's 
built-in message because it would mean nothing in to the User, as we 
are testing to see if they have left the menu in it's default unset 
state by checking the value is greater than 0.

2. We are making dynamic selectionlists by reading a db and outputting 
value/label pairs for woody, we need to add an entry at the beginning 
(representing the no selection above) whose text should be 
internationalised. How would you go about internationalising the string 
"Choose One" in the context of a flowscript below?


Sitemap snippet (we want to fall-back on the built-in woody messages):

<map:transformer name="i18n" 
src="org.apache.cocoon.transformation.I18nTransformer">
	<catalogues default="woody">
		<catalogue id="local" name="upload" location="content/i18n"/>
		<catalogue id="woody" name="WoodyMessages"
				location="context://samples/woody/messages"/>
	</catalogues>
	<cache-at-startup>true</cache-at-startup>
</map:transformer>


Woody Model snippet:

<wd:field id="category" required="true">
	<wd:label><i18n:text 
i18n:catalogue="local">upload.category.label</i18n:text>: </wd:label>
	<wd:hint><i18n:text 
i18n:catalogue="local">upload.category.hint</i18n:text></wd:hint>
	<wd:datatype base="long"/>
	<wd:validation>
		<wd:range min="1">
			<!-- i18n this string -->
		  	<wd:failmessage>Please choose one of these items.</wd:failmessage>
	    	</wd:range>
	</wd:validation>
	<wd:selection-list type="flow-jxpath"
		list-path="categories" value-path="value" label-path="label"/>
</wd:field>


FlowScript snippet:

function upload (form) {
	. . .
	var categories = getSelectionList (session, ImageCategory.ROLE);
	var types = getSelectionList (session, ImageType.ROLE);
	. . .
	form.showForm (screen, {categories: categories, types: types});
	. . .
}

function getSelectionList (session, classname) {
	var list = SimpleDescriptorPeer.list (session, classname);
	var selectionlist = new Array (list.size () +1);
	selectionlist[0] = {value: SimpleDescriptor.NO_VALUE, label: "Choose 
One"}; // i18n this string
	for (var i = 0; i < list.size (); i++)
		selectionlist[i+1] = {value: list.get (i).id, label: list.get 
(i).name};
	return out;
}

These sample points out another gritty little issue.
The flowscript uses SimpleDescriptor.NO_VALUE, fine, but Woody has to 
use <wd:range min="1"> while they are both referring to the same value 
(+1 in woody's case).

I have other situations where I would like to use Class constants as 
part of i18n message keys.


thanks for any suggestions


regards Jeremy







Mime
View raw message