Author: dmeikle Date: Mon May 18 18:10:18 2009 New Revision: 776029 URL: http://svn.apache.org/viewvc?rev=776029&view=rev Log: RESOURCES-7 : Pass Locale to MessageFormat
Modified: commons/sandbox/resources/trunk/src/main/java/org/apache/commons/resources/Messages.java commons/sandbox/resources/trunk/src/test/java/org/apache/commons/resources/MessagesTestCase.java commons/sandbox/resources/trunk/src/test/resources/org/apache/commons/resources/impl/LocalStrings.properties Modified: commons/sandbox/resources/trunk/src/main/java/org/apache/commons/resources/Messages.java URL: http://svn.apache.org/viewvc/commons/sandbox/resources/trunk/src/main/java/org/apache/commons/resources/Messages.java?rev=776029&r1=776028&r2=776029&view=diff ============================================================================== --- commons/sandbox/resources/trunk/src/main/java/org/apache/commons/resources/Messages.java (original) +++ commons/sandbox/resources/trunk/src/main/java/org/apache/commons/resources/Messages.java Mon May 18 18:10:18 2009 @@ -279,7 +279,7 @@ // TODO - Cache MessageFormat instances? String message = getMessage(resources, locale, key); - MessageFormat format = new MessageFormat(message); + MessageFormat format = new MessageFormat(message, locale); return (format.format(args)); } Modified: commons/sandbox/resources/trunk/src/test/java/org/apache/commons/resources/MessagesTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/resources/trunk/src/test/java/org/apache/commons/resources/MessagesTestCase.java?rev=776029&r1=776028&r2=776029&view=diff ============================================================================== --- commons/sandbox/resources/trunk/src/test/java/org/apache/commons/resources/MessagesTestCase.java (original) +++ commons/sandbox/resources/trunk/src/test/java/org/apache/commons/resources/MessagesTestCase.java Mon May 18 18:10:18 2009 @@ -121,6 +121,11 @@ Messages messages3 = messages2.getMessages(null); assertNull("Invalid Messages", messages3); + // Test for RESOURCES-7 + message = local.getMessage(Locale.US, "local.localetest", new Object[]{new Integer(100)}); + assertEquals("Jane has $100.00", message); + message = local.getMessage(Locale.UK, "local.localetest", new Object[]{new Integer(100)}); + assertEquals("Jane has \u00a3100.00", message); // u00a3 is pound sign for UTF-8 build } Modified: commons/sandbox/resources/trunk/src/test/resources/org/apache/commons/resources/impl/LocalStrings.properties URL: http://svn.apache.org/viewvc/commons/sandbox/resources/trunk/src/test/resources/org/apache/commons/resources/impl/LocalStrings.properties?rev=776029&r1=776028&r2=776029&view=diff ============================================================================== --- commons/sandbox/resources/trunk/src/test/resources/org/apache/commons/resources/impl/LocalStrings.properties (original) +++ commons/sandbox/resources/trunk/src/test/resources/org/apache/commons/resources/impl/LocalStrings.properties Mon May 18 18:10:18 2009 @@ -1,2 +1,3 @@ local.message=[Local] REPLACE {0} WITH {1} local.test=[Local] TEST +local.localetest=Jane has {0,number,currency}