Thanks for the link. Unfortunately, that appears to only talk about when your preferred locale isn't found at all (i.e. at the file level) and that's where JSTL and Struts diverge on finding the "next best match".

My problem is that I do have a resource file for the preferred locale, but it's missing some keys (i.e. at an individual property level). Struts will still traverse its parent chain, but JSTL won't. Once JSTL finds a resource file matching the locale, it seems to stop there.

I've read the JSR for JSTL at http://www.jcp.org/en/jsr/detail?id=52 and it leaves it sufficiently vague as to how missing keys within a resource should be handled. I suppose it's up to interpretation.

I'm curious if different implementations handle this differently. For my situation, I'm using Resin 2.1.14.

Angie


On Mar 25, 2005, at 5:55 AM, David Suarez wrote:

I haven't been using JSTL for i18n yet, just struts taglibs so I found
the below very interesting when considering a move...  I found this on
the web: http://www.junlu.com/msg/30187.html

The link suggests if you have a preferred approach, you can change the
jstl resources configured to be used so they match what you expect.
There's a code snippet in the link but I haven't tried it.  I would
guess you would configure the appropriate resources to use in a base
action or filter as mentioned in the link so that your front-end code
would never see it.  Please write back what you find, I'm very
interested in if you are able to change the i18n so it works as I'm
accustomed to.

Thanks!...djsuarez

-----Original Message-----
From: Angie Lin [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 24, 2005 7:34 PM
To: user@struts.apache.org
Subject: [OT] i18n: fmt:message versus bean:message

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









!DSPAM:424417f638071794613381!




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



Reply via email to