|
From: Keith D. <kd...@cs...> - 2004-03-31 22:42:11
|
For spring-rcp I have several bean declarations for configuring things =
like
actions, menus, and such--- basically beans whose properties need
internationalization.
=20
Wanted to make sure I am going about the best way of doing this:
=20
1. Initially, before adding internationalization support, I had these =
bean's
localizable properties simply specified manually in the bean =
configuration
xml. Not good.
=20
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)
=20
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:
=20
messages_en.properties
=20
# 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
=20
# DescriptionConfigurable: setCaption(String) / setDescription(String)
aboutAction.caption=3DDisplays an about dialog
aboutAction.description=3DThe about action long description...
=20
images_en.properties
=20
# ImageIconConfigurable: setIcon(ImageIcon)
aboutAction.icon=3Dcore/about.gif
=20
# ImageIconButtonConfigurable: rollover/pressed/disabled
aboutAction.rolloverIcon=3D..
aboutAction.pressedIcon=3D...
aboutAction.disabledIcon...
=20
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
|