struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angie Lin ...@heyang.org>
Subject [OT] i18n: fmt:message versus bean:message
Date Fri, 25 Mar 2005 01:33:45 GMT
This is off-topic, but in my Struts application, I've used all 
<fmt:message> tags instead of <bean:messsage> tags and I'm encountering 
issues with my l10n.

My questions:
1.  Is it correct that JSTL fmt:message will NOT follow the parent 
chain of resources at an individual property level?
2.  And is there anyway to force a parent chain?


(read on if for my test case)


I know that ResourceBundle establishes a parent chain by successively 
removing variant, country and language.  Struts does the same thing 
though it doesn't actually use ResourceBundle - it has 
PropertyMessageResources.

I know that JSTL doesn't follow the same lookup path.  It instead only 
looks for specific locales (ServletRequest.getLocales() listed in order 
of preference) with a possible fallback locale (if configured in 
web.xml).

However, I'm noticing that the fallback locale only appears to be used 
if the specific locale cannot be located at all.

Here is my situation:

   ApplicationResources.properties:
    greeting=Hello there!
    goodbye=See ya!

   ApplicationResources_en.properties:
    greeting=Hello!
    goodbye=Bye!

   ApplicationResources_es.properties:
    greeting=Hola!

Note that goodbye is missing from the spanish.

EXAMPLE A:
   Assume my browser preferred locale is 'es'.  And I have a 
fallbackLocale in web.xml set to 'en'.

   <bean:message key="greeting"/>
   <bean:message key="goodbye"/>
   <fmt:message key="greeting"/>
   <fmt:message key="goodbye">

   gives me

   Hola!
   See ya!
   Hola!
   ???goodbye???

The fallback is not even used.


EXAMPLE B:
  Assume my browser preferred locale is 'fr'.  And I have a 
fallbackLocale in web.xml set to 'en'

   <bean:message key="greeting"/>
   <bean:message key="goodbye"/>
   <fmt:message key="greeting"/>
   <fmt:message key="goodbye">

  gives me:

   Hello there!
   See ya!
   Hello!
   Bye!

The struts tags used the parent chain to fall back to 
ApplicationResources.properties.
But JSTL used the fallback of ApplicationResources_en.properties.


Thanks,
Angie








---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message