Commits

Anonymous committed cd41af1

Fixed bug where MessageFormat string was being parsed before the locale was set, so dates and numbers were not localized

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@352e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 6861339

Comments (0)

Files changed (3)

File src/java/com/opensymphony/xwork/util/LocalizedTextUtil.java

     }
 
     private static MessageFormat buildMessageFormat(String pattern, Locale locale) {
-        MessageFormat format = new MessageFormat(pattern);
+        MessageFormat format = new MessageFormat("");
         format.setLocale(locale);
+        format.applyPattern(pattern);
 
         return format;
     }

File src/test/com/opensymphony/xwork/util/LocalizedTextUtilTest.java

 import java.util.Collections;
 import java.util.Locale;
 import java.util.MissingResourceException;
+import java.util.Date;
 
 
 /**
         }
     }
 
+    public void testLocalizedDateFormatIsUsed() {
+        LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/xwork/util/LocalizedTextUtilTest");
+        Object[] params = new Object[] {new Date()};
+        String usDate = LocalizedTextUtil.findDefaultText("test.format.date",Locale.US,params);
+        String frenchDate = LocalizedTextUtil.findDefaultText("test.format.date",Locale.FRANCE,params);
+        assertFalse(usDate.equals(frenchDate));
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         ConfigurationManager.destroyConfiguration();

File src/test/com/opensymphony/xwork/util/LocalizedTextUtilTest.properties

+test.format.date={0,date,short}