Re: i18n

Shash Chatterjee <[email protected]> Sat, 27 Aug 2005 14:30:29 -0500
Newsgroups gmane.comp.java.keel.devel
Message-ID <[email protected]>
Raoul,

Thanks for getting this done, this is an useful feature.

- I could use this, so started trying already.  I ran into a problem
about the keel-resources.xml file not parsing, SAX complained that it is
not well-formed after root elements.  I enclosed the generated file
withing <resources></resources> (just made up the root element), and it
worked.

- Looks like the old resources are still under conf/client/struts. 
Hopefully, we don't need to duplicate, right? Same set of  resources can
be used by both Struts/keel-client, correct?

- Since the i18n code is in keel-common, it'd be really cool to share
the same resources between both the Keel client and server sides, if one
wanted to. We could put a translator class in keel-server as well, and
we'd have to package resources both in the client and server JARs.  That
way even error logs and such could be i18n-alized.

Shash

>
>
> I just commited patches to move dynamic message from clnt-struts to
> keel-client.
>
> The treatment of dynamic messages is now implanted in
> DefaultClientConnector. The job is done by an new class
> DynamicMessageSupport in keel-common, with Apache library
> commons-resources.
>
> I moved the properties files from conf/client/struts to
> conf/clients/resource, a more client neutral place. I used
> ResourceBundle Editor for Eclipse to sort the messages: very nice tool
> to work with i18n messages.
>
> Howto :
>
> Below "key" is the symbolic name of a bundle.
>
> - In each direct sub-class of DefaultClientConnector, defined a
> function setDefaultKeys, which can add  key(s) to the default key
> list. This function can be called from function "execute" as soon as
> kres is defined with a "model" attribute (if required).
>  This function "setDefaultKeys" must call:
>  * DefaultClientConnector.initDefaultKeys(kres) to initialize the
> default key list,
>  * then DefaultClientConnector.getDefaultKeys() to get this default
> key list and add new key(s).
>
>  Use DefaultClientConnector.addFirstDefaultKey(...) and
> DefaultClientConnector.addLastDefaultKey(...)  to add any key at the
> beginning or at the end of the list.
>  It is recommended to defined setDefaultKeys as private.
>
> - In a derived class, e.g. StrutsClientConnector, in function
> "execute"  insert a call to
> DefaultClientConnector.internationalize(...). This function will do
> all the job!
>
>  It is also possible to call
> DefaultClientConnector.translateString(...), like
> StrutsClientConnector with the error messages.
>
>  Normally,  sub-classes don't need to do anything else about i18n but
> eventually to define their own function setDefaultKeys.
>
> ====
>
> AbstractDesktopClientConnector is ready to i18n.
>
> Todo:
> - put i18n in non Struts Client connectors
> - it may be necessary to add script(s) in plugin.jelly
> (tool-maven-plugin) for clients other than Struts.
> - add a function "translateMessage" in DefaultClientConnector.
> - in StrutsClientConnector.errorhandle,  do a "final" translation of
> error messages.