cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Re: i18n Translations to String
Date Fri, 17 Nov 2006 13:09:56 GMT

On 16 Nov 2006, at 16:55, Vadim Gritsenko wrote:

> Jeremy Quinn wrote:
>> Hi All
>> I am close to finishing an UploadProgressBar Dojo Widget for  
>> CForms and am trying to implement i18n status messages.
>> I have a FlowScript that reads the upload status and sends this as  
>> JSON to the UploadProgressBar.
>> I was trying to avoid using JXTemplate for the serialization,  
>> instead, I serialize the data (a Map) to JSON in FlowScript and  
>> send it using :
>>     <map:match pattern="send-json">
>>        <map:read src="module:flow-attr:json" mime-type="text/ 
>> javascript" />
>>     </map:match>
>> I was hoping to do i18n lookup in FlowScript using  
>> o.a.c.forms.util.I18nMessage but of course it outputs SAX events,  
>> not Strings :(
>> I will either have to switch to using JXT for serialization, or  
>> find an alternative i18n lookup mechanism.
>> Any suggestions anyone ?
>
> I18nMessage does not do lookups: I18nTransformer does.
>
> Now if you want to play I18nTransformer in Flow, you need to lookup  
> catalogue from XMLResourceBundleFactory, and then you can translate  
> the key into String using XMLResourceBundle.getString(key) method.  
> You'll lose any HTML markup which was in the translation, you'll  
> get only message text.


Hi Vadim,

I guess this thread is turning into one about JSON Serialization in  
general .....


Now I need to work out how to do the above from FlowScript, when my  
i18n messages may have parameters, eg :

   <message key="upload.progress.sent">Sent: {0}% ({1} of {2} bytes).  
Filename: {3}.</message>

I have not worked out yet how I18nTransformer does this ....

Ideally, one should be able to get a String which contains any tags  
that were in the i18n Message, as widgets may want to use these, by  
injecting them as InnerHTML.



JSON Serialization, we need better solutions ....

I am currently using JXT for serializing the JSON Response (as this  
allows the use of XMLizable I18nMessage), but it is a pretty foul way  
of doing it. I am not sure that JXT is able to determine the class of  
Objects in a nice way, I tried this :

	<jx:when test"${item instanceof Packages.java.lang.Number}"> . . . </ 
jx:when>

But jexl does not like 'instanceof'.

This means that my serialization currently has to turn everything  
into a String. (yuk)



What kind of Objects should we expect to be serializing to JSON ?

   JavaScript: Objects, functions and primitives: should be easy once  
FlowScript is updated to have .toSource().

   Java: Maps, Collections, Strings, Numbers, Booleans, Dates,  
primitives: use generic FlowScript (could be adapted from Dojo's code?)?

   Java: POJOs : use Jettison ?

   Java: I18n Message Strings : a must-have ..... Dojo's i18n  
mechanism is not in place yet, without this it will be very difficult  
to i18n dojo widgets. We may not even want to have 2 i18n mechanisms  
with 2 types of resource file format.


ATM, we only have 2 widgets that use JSON, but IMHO this number will  
grow. We also need a clear route for people developing their own  
widgets, so can we all have a think about this ?

:)

Thanks guys

regards Jeremy





Mime
View raw message