Ah, our good friend localization.

The first question is: why would you need to change locale?

The locale the server operates in should not be related to the locale of any client 
(whether via
HTTP, SOAP, RMI, etc.).

In HiveMind, localized strings can creep into all sorts of places via the "%" message 
property. For
example:

 <extension ...>
  <banner-message message="%welcome"/>

That may be converted to a BannerMessage instance whose message property is "Welcome!".

If you (could) change the registry's locale to French, the message property will stay 
"Welcome!"
because the XML has already been conveted to Java objects; there's no opportunity now 
to change it
to "Bonjour". On top of that, after the conversion, the XML is (in the current 
implementation)
discarded because conversion takes place once, and the converted objects are simply 
retained for any
later use, so there's no point in keeping the XML.

There's a thicket of ambiguities there; one possible solution is, as you did, to 
re-create the
registry with the new locale and discard the old one. That runs the risk of an old 
reference to an
old service in some part of your application ... duelling registries and lots of 
confusion!

I suppose we could keep the XML for extensions after the conversion, and do some 
clever stuff with
events to know when the registry's locale changes ... but localized strings can creep 
into all kinds
of places, such as service implementation properties (via the BuilderFactory) or many, 
many other
places beyond the frameworks knowledge or control.

The question is: how big an issue is this? How often do server's locales change on the 
fly?

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Bill Lear [mailto:[EMAIL PROTECTED] 
> Sent: Monday, September 15, 2003 6:02 PM
> To: [EMAIL PROTECTED]
> Subject: [HiveMind] Question about setting the locale
> 
> 
> The HiveMind doc states:
> 
>      When a Registry  is created by the RegistryBuilder  , a locale is
>      specified. This is the locale for the Registry and, by extension,
>      for all Modules in the registry. The locale may not be changed.
> 
> So, should the application need to respond to a change in 
> locale during run-time, does this mean that a new registry 
> will need to be built?  Something like this, perhaps:
> 
>         // maps locale to associated registry
>         Map registryMap = new HashMap();
> 
>         Registry getRegistryForLocale(Locale locale) {
>             Registry registry = (Registry) registryMap.get(locale);
>             if (registry == null) {
>                 ClassResolver resolver = new DefaultClassResolver();
>                 RegistryBuilder builder = new RegistryBuilder();
>                 builder.processModules(resolver);
>                 registry = builder.constructRegistry(locale);
>                 registryMap.put(locale, registry);
>             }
>             return registry;
>         }
> 
> Would this work, be efficient, etc.?  Or am I missing something?
> 
> 
> Bill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to