geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "B.J. Reed" <>
Subject using Resource Bundles for message strings
Date Tue, 26 Feb 2008 15:30:14 GMT
I have written a patch to get Geronimo messages from a common set of 
resource bundles.  Included in the patch is the,, and the 
start of the file.

The patch should be unzipped into the 
trunk/framework/modules/geronimo-common directory.  Please take a look 
and provide suggestions/comments/etc.  I would like to really begin 
moving messages into this common file - probably a module at a time.


1) How do I use the new class in the Geronimo code?  So that we don't 
load the list of messages and keys multiple times, the 
GeronimoMessageBundle is a singleton.  Simply make a call to 
GeronimoMessageBundle.getInstance() and then make the appropriate 
getMessage call.  For starters, I have made the message key the message 
number that will show up as part of the message.  Also provided is a way 
to substitute parts of the message with substitution strings.

2) Is there a numbering standard for the key?  The standard that I have 
started for the message key is as follows:
    mmmm - 4 char module name abbreviation
    l - one char level (E - error, W - warning, I - information
    xxxx - 4 digit error number
Since I haven't gotten very far...if there is a better suggestion, then 
it will be easier to change this sooner rather than later.

3)  Tell me more about the string substitutions.  To make messages more 
flexible, placeholders can be put in the messages that look like {0} {1} 
etc.  An ArrayList can be passed in to the getMessage method that will 
be used to replace the placeholders.  This way, if a language needs the 
replacements in a different order, the code will not need to be changed.

4)  How do I add a language?  At this time, the is included in the geronimo-common.jar.  
The easiest thing that I have found is to copy the .properties file to 
an apprpriate locale named file  ( (for 
German) or for German in 
Switzerland).  Re-create the geronimo-common.jar file.  Right now, the 
machine locale is used.  After we have several translations, we may want 
to add something to the Admin Console to allow an administrator to set 
the locale.

5)  Is there a way to have the .properties file(s) outside of the jar?  
I'm sure there is, but I haven't stumbled across it yet.  That's 
actually where I've been banging my head the last few days.

6)  I also envision that when we have all the messages in the common 
file, that it will be very easy to have a troubleshooting section on our 
website that gives more in depth knowledge about each message.

I will begin writing 2.2 documentation from the above questions.

This is just for message translation, so I believe that we'll need to 
come up with other methods for the Admin Console and possibly the 
Eclipse plugin if we want to have everything translatable.

-- B.J. Reed

View raw message