|
From: Rod J. <rod...@in...> - 2004-04-02 21:23:54
|
MessageCool. Let me know if I can help.
----- Original Message -----=20
From: Keith Donald=20
To: spr...@li...=20
Sent: Thursday, April 01, 2004 8:15 PM
Subject: [Springframework-developer] RE: internationalizing bean =
properties
I got to thinking about this some more and I think there is a better =
way to support internationalization of bean property values---attributes =
metadata.
For example, if I do this:
/**
* @@Translatable
*/
public void setMyTranslatableProperty(String property);
... the bean post processor could notice the @@Translatable attribute =
and then know to load the string value from a message source, then set =
it. I could also use introduction to attach internationalized =
"descriptor" classes (having stuff like name, caption, description) =
which are "common" properties needed when representing an object in a =
GUI (for the label, tooltip, and detailed description, for example.)
IoC+AOP+Metadata is quite enabling! All kinds of stuff seems possible =
that just wasn't before. Keith
-----Original Message-----
From: Keith Donald [mailto:kd...@cs...]=20
Sent: Wednesday, March 31, 2004 5:42 PM
To: 'spr...@li...'
Subject: internationalizing bean properties
For spring-rcp I have several bean declarations for configuring =
things like actions, menus, and such--- basically beans whose properties =
need internationalization.
Wanted to make sure I am going about the best way of doing this:
1. Initially, before adding internationalization support, I had =
these bean's localizable properties simply specified manually in the =
bean configuration xml. Not good.
Since I must provide internationalization of the GUI I've considered =
two options:
- use a property placeholder configurer to inject localized =
property values from some properties file
- use a bean post processor to retrieve localized =
properties/icons from message source and image source (before bean =
initialization)
I've just implemented the latter, as it simplifies the XML code (I =
no longer have to specify values or variable names for the resolvable =
properties in xml) - the bean post processor attempts to resolve =
configuration values by checking to see if a bean implements a certain =
"DescriptionConfigurable" or "LabelConfigurable" or =
"ImageIconConfigurable" interface, for example. The beanName is used as =
a prefix to the resolved message/image code. So for example, for the =
"aboutAction" bean you'd see:
messages_en.properties
# LabelConfigurable interface: setLabel(LabelInfo)
# (The '&' is the displayed mnemonic + index and the @ references =
the accelerator key - adapted from Eclipse's format.)
aboutAction.label=3D&About @ CTRL-A
# DescriptionConfigurable: setCaption(String) / =
setDescription(String)
aboutAction.caption=3DDisplays an about dialog
aboutAction.description=3DThe about action long description...
images_en.properties
# ImageIconConfigurable: setIcon(ImageIcon)
aboutAction.icon=3Dcore/about.gif
# ImageIconButtonConfigurable: rollover/pressed/disabled
aboutAction.rolloverIcon=3D..
aboutAction.pressedIcon=3D...
aboutAction.disabledIcon...
Seems like a pretty good approach, and simplifies the beans =
themselves a lot since they don't have to deal with message or image =
lookup. Just wanted to post for comments and if there is anything I =
should be aware of... Keith |