portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Evans" <jon.ev...@misgl.com>
Subject Re: [patch] JetspeedLocalizationService
Date Tue, 04 Mar 2003 12:56:30 GMT
Hi David,

David Sean Taylor wrote:

> The patch isn't necessary I just committed a patch from
> Missimilliano Dessi. It works fine as is. Although I thought we had
> country flag icons with the original portlet.

I have just got round to using the latest CVS.  I like the fact that
the changeLanguage portlet is now a .vm, it will make it a lot easier
to change the look and feel for my site.

I'm still concerned though with

It still doesn't seem to work if you have more than one bundle defined
in locale.default.bundles.  It only seems to look at the first bundle.

If you look at the class, it extends TurbineLocalizationService.
JetspeedLocalizationService implements an initBundleNames() method
which populates an instance variable String[] bundleNames.  But all of
the getString(...) methods call super.getString(...), where
TurbineLocalizationService will use its own instance variables and will
not find the strings.

Let me put it another way.  Each class defines an identical set of 
instance variables, like this:

JetspeedLocalizationService     TurbineLocalizationService
=============================== ===============================
private Hashtable bundles;      private Hashtable bundles;
private String bundleNames[];   private String bundleNames[];
private Locale defaultLocale;   private Locale defaultLocale;
private String defaultLanguage; private String defaultLanguage;
private String defaultCountry;  private String defaultCountry;

After JetspeedLocalizationService.init() is called they look like this:

JetspeedLocalizationService TurbineLocalizationService
=========================== ==========================
bundles          null       bundles         set
bundleNames[]    set        bundleNames[]   null
defaultLocale    null       defaultLocale   set
defaultLanguage  null       defaultLanguage set
defaultCountry   null       defaultCountry  set

when getString(String bundleName, Locale locale, String key) is called
in JetspeedLocalizationService, it calls super.getString(...).  This
calls getBundle(String, Locale), which is implemented in
JetspeedLocalizationService as a call to super.getBundle(String,
Locale), so we are back to the code in TurbineLocalizationService.

getBundle(String, Locale) in TurbineLocalizationService returns the
default bundle to the getString(...) method.

Back in getString(String bundleName, Locale locale, String key), we
look up the requested key in the bundle, using getStringOrNull(), which 
returns null because the string I'm looking for isn't in the first 
bundle, it's in the second.

The next test is intended to determine whether we need to check the
other bundles for the key.  The test is:

         // Look for text in list of default bundles.
         if (value == null && bundleNames.length > 0)

At this point we throw a NullPointerException because bundleNames is
null (it was never set in TurbineLocalizationService, only in

The whole of the JetspeedLocalizationService class can be reduced to a 
single function, getLocale(RunData runData).

The attached patch does this, and seems to work.  Yes, I compiled from 
clean this time. :-)

Merlin Information Systems Limited, 
Merlin House, Gawcott Road, Buckingham, United Kingdom. MK18 1TN
Tel: +44 (0) 1280 824331  Fax: +44 (0) 1280 824112

Provider of IT Services and Online Portal Support Services. 
The information contained in this email (including any attachments) is confidential and is
intended solely for the use of the named addressee. Access, copying or re-use of the information
in it by any other person is not authorised. If you are not the intended recipient, please
notify us immediately by telephone or by e-mail to admin@misgl.com

*** This mail has been scanned for viruses ***


View raw message