struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 20468] New: - MessageResources always uses the default Locale for MessageFormats
Date Wed, 04 Jun 2003 08:37:35 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20468>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20468

MessageResources always uses the default Locale for MessageFormats

           Summary: MessageResources always uses the default Locale for
                    MessageFormats
           Product: Struts
           Version: Nightly Build
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Utilities
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: bert.scheel@dhl.com


Problem:
The following code fragment in an Action
  Locale myLocale = getLocale(myHttpServletRequest);
  MessageResources myResources = getResources();
  Date myDate = new Date();
  String myString = myResources.getMessage(myLocale, "format.date", myDate);
should result in a String of the form "04.06.2003" or "04 Jun 2003" depending 
on the Locale (german or english) when format.date={0,date,medium} but the 
default Locale is used in both cases. The reason for this is the codeline:
  format = new MessageFormat(escape(formatString));
in the method:
  public String getMessage(Locale locale, String key, Object args[])
No Locale is provided in the constructor, therefore the default Locale is used.

Solution:
Replace the above codeline by:
  MessageFormat myMessageFormat = new MessageFormat("");
  myMessageFormat.setLocale(myLocale);
  myMessageFormat.applyPattern(escape(myStringFormat));

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


Mime
View raw message