tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r594663 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry/internal/services/ tapestry-core/src/main/java/org/apache/tapestry/internal/test/ tapestry-core/src/main/java/org/apache/tapestry/test/ tapestry-ioc/src...
Date Tue, 13 Nov 2007 22:01:23 GMT
Author: hlship
Date: Tue Nov 13 14:01:22 2007
New Revision: 594663

URL: http://svn.apache.org/viewvc?rev=594663&view=rev
Log:
TAPESTRY-1882: Formatted messages are not localized properly

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MapMessages.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MessagesSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessagesImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MapMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MapMessages.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MapMessages.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MapMessages.java
Tue Nov 13 14:01:22 2007
@@ -22,6 +22,7 @@
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.util.AbstractMessages;
 
+import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -31,13 +32,16 @@
 {
     private final Map<String, String> _properties;
 
+
     /**
      * A new instance <strong>retaining</strong> (not copying) the provided map.
      */
-    public MapMessages(final Map<String, String> properties)
+    public MapMessages(Locale locale, Map<String, String> properties)
     {
+        super(locale);
         _properties = properties;
     }
+
 
     @Override
     protected String valueForKey(String key)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MessagesSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MessagesSourceImpl.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MessagesSourceImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/MessagesSourceImpl.java
Tue Nov 13 14:01:22 2007
@@ -95,7 +95,7 @@
     {
         Map<String, String> properties = findBundleProperties(bundle, locale);
 
-        return new MapMessages(properties);
+        return new MapMessages(locale, properties);
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
Tue Nov 13 14:01:22 2007
@@ -71,10 +71,9 @@
 
         // A synthetic module to ensure that the tapestry.alias-mode is set correctly.
 
-        SymbolProvider provider = new SingleKeySymbolProvider(
-                InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL, "servlet");
-        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode",
-                                                                                provider,
"before:ApplicationDefaults");
+        SymbolProvider provider = new SingleKeySymbolProvider(InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL,
"servlet");
+        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode",
provider,
+                                                                                "before:ApplicationDefaults");
 
         ModuleDef module = new SyntheticModuleDef(contribution);
 
@@ -146,8 +145,8 @@
         return newMock(ComponentTemplate.class);
     }
 
-    protected final <T> void train_getService(InternalRegistry registry, String serviceId,
-                                              Class<T> serviceInterface, T service)
+    protected final <T> void train_getService(InternalRegistry registry, String serviceId,
Class<T> serviceInterface,
+                                              T service)
     {
         expect(registry.getService(serviceId, serviceInterface)).andReturn(service);
 
@@ -183,8 +182,7 @@
         return newMock(RenderQueue.class);
     }
 
-    protected final void train_parseTemplate(TemplateParser parser, Resource resource,
-                                             ComponentTemplate template)
+    protected final void train_parseTemplate(TemplateParser parser, Resource resource, ComponentTemplate
template)
     {
         expect(parser.parseTemplate(resource)).andReturn(template);
     }
@@ -219,8 +217,8 @@
         expect(request.getContextPath()).andReturn(contextPath).atLeastOnce();
     }
 
-    protected final void train_resolvePageClassNameToPageName(ComponentClassResolver resolver,
-                                                              String pageClassName, String
pageName)
+    protected final void train_resolvePageClassNameToPageName(ComponentClassResolver resolver,
String pageClassName,
+                                                              String pageName)
     {
         expect(resolver.resolvePageClassNameToPageName(pageClassName)).andReturn(pageName);
     }
@@ -230,8 +228,7 @@
         expect(element.getContainingPage()).andReturn(page).atLeastOnce();
     }
 
-    protected final void train_getComponentResources(ComponentPageElement element,
-                                                     InternalComponentResources resources)
+    protected final void train_getComponentResources(ComponentPageElement element, InternalComponentResources
resources)
     {
         expect(element.getComponentResources()).andReturn(resources).atLeastOnce();
     }
@@ -241,8 +238,8 @@
         expect(model.getComponentClassName()).andReturn(className).atLeastOnce();
     }
 
-    protected final void train_newRenderBodyElement(PageElementFactory elementFactory,
-                                                    ComponentPageElement component, PageElement
body)
+    protected final void train_newRenderBodyElement(PageElementFactory elementFactory, ComponentPageElement
component,
+                                                    PageElement body)
     {
         expect(elementFactory.newRenderBodyElement(component)).andReturn(body);
     }
@@ -257,21 +254,13 @@
         expect(model.getParameterNames()).andReturn(Arrays.asList(names));
     }
 
-    protected final void train_newComponentElement(PageElementFactory elementFactory,
-                                                   ComponentPageElement container, String
embeddedId,
-                                                   String embeddedType,
-                                                   String componentClassName, String elementName,
Location location,
-                                                   ComponentPageElement embedded)
-    {
-        expect(
-                elementFactory.newComponentElement(
-                        isA(Page.class),
-                        eq(container),
-                        eq(embeddedId),
-                        eq(embeddedType),
-                        eq(componentClassName),
-                        eq(elementName),
-                        eq(location))).andReturn(embedded);
+    protected final void train_newComponentElement(PageElementFactory elementFactory, ComponentPageElement
container,
+                                                   String embeddedId, String embeddedType,
String componentClassName,
+                                                   String elementName, Location location,
ComponentPageElement embedded)
+    {
+        expect(elementFactory.newComponentElement(isA(Page.class), eq(container), eq(embeddedId),
eq(embeddedType),
+                                                  eq(componentClassName), eq(elementName),
eq(location))).andReturn(
+                embedded);
     }
 
     protected final void train_getComponentType(EmbeddedComponentModel emodel, String componentType)
@@ -320,8 +309,8 @@
         expect(model.getEmbeddedComponentIds()).andReturn(Arrays.asList(ids));
     }
 
-    protected void train_getTemplate(ComponentTemplateSource templateSource, ComponentModel
model,
-                                     Locale locale, ComponentTemplate template)
+    protected void train_getTemplate(ComponentTemplateSource templateSource, ComponentModel
model, Locale locale,
+                                     ComponentTemplate template)
     {
         expect(templateSource.getTemplate(model, locale)).andReturn(template);
     }
@@ -331,11 +320,10 @@
         expect(resources.getComponentModel()).andReturn(model).atLeastOnce();
     }
 
-    protected final void train_newRootComponentElement(PageElementFactory elementFactory,
-                                                       String className, ComponentPageElement
rootElement)
+    protected final void train_newRootComponentElement(PageElementFactory elementFactory,
String className,
+                                                       ComponentPageElement rootElement)
     {
-        expect(elementFactory.newRootComponentElement(isA(Page.class), eq(className))).andReturn(
-                rootElement);
+        expect(elementFactory.newRootComponentElement(isA(Page.class), eq(className))).andReturn(rootElement);
     }
 
     protected final void train_getModel(Instantiator ins, ComponentModel model)
@@ -358,8 +346,7 @@
         return newMock(RequestPageCache.class);
     }
 
-    protected final void train_getComponentElementByNestedId(Page page, String nestedId,
-                                                             ComponentPageElement element)
+    protected final void train_getComponentElementByNestedId(Page page, String nestedId,
ComponentPageElement element)
     {
         expect(page.getComponentElementByNestedId(nestedId)).andReturn(element).atLeastOnce();
     }
@@ -389,8 +376,7 @@
         return newMock(ResourceCache.class);
     }
 
-    protected final void train_requiresDigest(ResourceCache cache, Resource resource,
-                                              boolean requiresChecksum)
+    protected final void train_requiresDigest(ResourceCache cache, Resource resource, boolean
requiresChecksum)
     {
         expect(cache.requiresDigest(resource)).andReturn(requiresChecksum);
     }
@@ -400,8 +386,7 @@
         return newMock(InvalidationListener.class);
     }
 
-    protected final void train_getTimeModified(ResourceCache cache, Resource resource,
-                                               long timeModified)
+    protected final void train_getTimeModified(ResourceCache cache, Resource resource, long
timeModified)
     {
         expect(cache.getTimeModified(resource)).andReturn(timeModified).atLeastOnce();
     }
@@ -416,8 +401,8 @@
         expect(cache.get(pageName)).andReturn(page).atLeastOnce();
     }
 
-    protected final void train_findPageTemplateResource(PageTemplateLocator locator,
-                                                        ComponentModel model, Locale locale,
Resource resource)
+    protected final void train_findPageTemplateResource(PageTemplateLocator locator, ComponentModel
model,
+                                                        Locale locale, Resource resource)
     {
         expect(locator.findPageTemplateResource(model, locale)).andReturn(resource).atLeastOnce();
     }
@@ -437,7 +422,7 @@
             ResourceBundle bundle = ResourceBundle
                     .getBundle("org.apache.tapestry.internal.ValidationMessages");
 
-            _validationMessages = new MessagesImpl(bundle);
+            _validationMessages = new MessagesImpl(Locale.ENGLISH, bundle);
         }
 
         return _validationMessages;
@@ -473,8 +458,7 @@
         expect(resolver.isPageName(isA(String.class))).andStubReturn(result);
     }
 
-    protected final void train_isPageName(ComponentClassResolver resolver, String pageName,
-                                          boolean result)
+    protected final void train_isPageName(ComponentClassResolver resolver, String pageName,
boolean result)
     {
         expect(resolver.isPageName(pageName)).andReturn(result);
     }
@@ -522,8 +506,8 @@
         return newMock(DocumentHeadBuilder.class);
     }
 
-    protected final void train_canonicalizePageName(ComponentClassResolver resolver,
-                                                    String pageName, String canonicalized)
+    protected final void train_canonicalizePageName(ComponentClassResolver resolver, String
pageName,
+                                                    String canonicalized)
     {
         expect(resolver.canonicalizePageName(pageName)).andReturn(canonicalized);
     }
@@ -533,8 +517,8 @@
         expect(page.getLogicalName()).andReturn(logicalName).atLeastOnce();
     }
 
-    protected final void train_resolvePageNameToClassName(ComponentClassResolver resolver,
-                                                          String pageName, String pageClassName)
+    protected final void train_resolvePageNameToClassName(ComponentClassResolver resolver,
String pageName,
+                                                          String pageClassName)
     {
         expect(resolver.resolvePageNameToClassName(pageName)).andReturn(pageClassName)
                 .atLeastOnce();

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
Tue Nov 13 14:01:22 2007
@@ -67,8 +67,7 @@
         return new MarkupWriterImpl();
     }
 
-    protected final void train_getAliasesForMode(AliasManager manager, String mode,
-                                                 Map<Class, Object> configuration)
+    protected final void train_getAliasesForMode(AliasManager manager, String mode, Map<Class,
Object> configuration)
     {
         expect(manager.getAliasesForMode(mode)).andReturn(configuration);
     }
@@ -325,29 +324,28 @@
         }
     }
 
-    protected final void train_addField(ClassTransformation transformation, int modifiers,
-                                        String type, String suggestedName, String actualName)
+    protected final void train_addField(ClassTransformation transformation, int modifiers,
String type,
+                                        String suggestedName, String actualName)
     {
         expect(transformation.addField(modifiers, type, suggestedName)).andReturn(actualName);
     }
 
-    protected final void train_addInjectedField(ClassTransformation ct, Class type,
-                                                String suggestedName, Object value, String
fieldName)
+    protected final void train_addInjectedField(ClassTransformation ct, Class type, String
suggestedName, Object value,
+                                                String fieldName)
     {
         expect(ct.addInjectedField(type, suggestedName, value)).andReturn(fieldName);
     }
 
-    protected final void train_addMethod(ClassTransformation transformation,
-                                         TransformMethodSignature signature, String... body)
+    protected final void train_addMethod(ClassTransformation transformation, TransformMethodSignature
signature,
+                                         String... body)
     {
         transformation.addMethod(eq(signature), codeEq(join(body)));
     }
 
-    protected final void train_buildConstraints(ValidationConstraintGenerator generator,
-                                                Class propertyType, AnnotationProvider provider,
String... constraints)
+    protected final void train_buildConstraints(ValidationConstraintGenerator generator,
Class propertyType,
+                                                AnnotationProvider provider, String... constraints)
     {
-        expect(generator.buildConstraints(propertyType, provider)).andReturn(
-                Arrays.asList(constraints));
+        expect(generator.buildConstraints(propertyType, provider)).andReturn(Arrays.asList(constraints));
     }
 
     protected final <T> void train_create(ApplicationStateCreator<T> creator,
T aso)
@@ -360,18 +358,12 @@
         expect(factory.createAsset(resource)).andReturn(asset);
     }
 
-    protected final void train_createValidator(FieldValidatorSource source, Field field,
-                                               String validatorType, String constraintValue,
String overrideId,
-                                               Messages overrideMessages, Locale locale,
FieldValidator result)
-    {
-        expect(
-                source.createValidator(
-                        field,
-                        validatorType,
-                        constraintValue,
-                        overrideId,
-                        overrideMessages,
-                        locale)).andReturn(result);
+    protected final void train_createValidator(FieldValidatorSource source, Field field,
String validatorType,
+                                               String constraintValue, String overrideId,
Messages overrideMessages,
+                                               Locale locale, FieldValidator result)
+    {
+        expect(source.createValidator(field, validatorType, constraintValue, overrideId,
overrideMessages,
+                                      locale)).andReturn(result);
     }
 
     protected final void train_encodeRedirectURL(Response response, String URI, String encoded)
@@ -384,8 +376,8 @@
         expect(response.encodeURL(inputURL)).andReturn(outputURL);
     }
 
-    protected final <T> void train_exists(ApplicationStatePersistenceStrategy strategy,
-                                          Class<T> asoClass, boolean exists)
+    protected final <T> void train_exists(ApplicationStatePersistenceStrategy strategy,
Class<T> asoClass,
+                                          boolean exists)
     {
         expect(strategy.exists(asoClass)).andReturn(exists);
     }
@@ -395,14 +387,13 @@
         transformation.extendConstructor(codeEq(join(body)));
     }
 
-    protected final void train_extendMethod(ClassTransformation transformation,
-                                            TransformMethodSignature signature, String...
body)
+    protected final void train_extendMethod(ClassTransformation transformation, TransformMethodSignature
signature,
+                                            String... body)
     {
         transformation.extendMethod(eq(signature), codeEq(join(body)));
     }
 
-    protected final void train_findAsset(AssetSource source, Resource root, String path,
-                                         Locale locale, Asset asset)
+    protected final void train_findAsset(AssetSource source, Resource root, String path,
Locale locale, Asset asset)
     {
         expect(source.findAsset(root, path, locale)).andReturn(asset);
     }
@@ -457,26 +448,24 @@
         expect(tf.findMethodsWithAnnotation(annotationType)).andReturn(sigs);
     }
 
-    protected final void train_findUnclaimedFields(ClassTransformation transformation,
-                                                   String... fieldNames)
+    protected final void train_findUnclaimedFields(ClassTransformation transformation, String...
fieldNames)
     {
         expect(transformation.findUnclaimedFields()).andReturn(Arrays.asList(fieldNames));
     }
 
-    protected final void train_generateChecksum(ResourceDigestGenerator generator, URL url,
-                                                String digest)
+    protected final void train_generateChecksum(ResourceDigestGenerator generator, URL url,
String digest)
     {
         expect(generator.generateDigest(url)).andReturn(digest);
     }
 
-    protected final <T> void train_get(ApplicationStatePersistenceStrategy strategy,
-                                       Class<T> asoClass, ApplicationStateCreator<T>
creator, T aso)
+    protected final <T> void train_get(ApplicationStatePersistenceStrategy strategy,
Class<T> asoClass,
+                                       ApplicationStateCreator<T> creator, T aso)
     {
         expect(strategy.get(asoClass, creator)).andReturn(aso);
     }
 
-    protected final void train_get(ApplicationStatePersistenceStrategySource source,
-                                   String strategyName, ApplicationStatePersistenceStrategy
strategy)
+    protected final void train_get(ApplicationStatePersistenceStrategySource source, String
strategyName,
+                                   ApplicationStatePersistenceStrategy strategy)
     {
         expect(source.get(strategyName)).andReturn(strategy).atLeastOnce();
     }
@@ -516,8 +505,7 @@
         expect(source.getClasspathAsset(path)).andReturn(asset);
     }
 
-    protected final void train_getClasspathAsset(AssetSource source, String path, Locale
locale,
-                                                 Asset asset)
+    protected final void train_getClasspathAsset(AssetSource source, String path, Locale
locale, Asset asset)
     {
         expect(source.getClasspathAsset(path, locale)).andReturn(asset);
     }
@@ -537,8 +525,7 @@
         expect(model.getComponentClassName()).andReturn(className).atLeastOnce();
     }
 
-    protected final void train_getComponentResources(Component component,
-                                                     ComponentResources resources)
+    protected final void train_getComponentResources(Component component, ComponentResources
resources)
     {
         expect(component.getComponentResources()).andReturn(resources).atLeastOnce();
     }
@@ -558,8 +545,7 @@
         expect(resources.getContainer()).andReturn(container).atLeastOnce();
     }
 
-    protected final void train_getContainerMessages(ComponentResources resources,
-                                                    Messages containerMessages)
+    protected final void train_getContainerMessages(ComponentResources resources, Messages
containerMessages)
     {
         expect(resources.getContainerMessages()).andReturn(containerMessages).atLeastOnce();
     }
@@ -575,21 +561,19 @@
         expect(request.getDateHeader(name)).andReturn(value).atLeastOnce();
     }
 
-    protected final <T extends Annotation> void train_getFieldAnnotation(
-            ClassTransformation transformation, String fieldName, Class<T> annotationClass,
-            T annotation)
+    protected final <T extends Annotation> void train_getFieldAnnotation(ClassTransformation
transformation,
+                                                                         String fieldName,
Class<T> annotationClass,
+                                                                         T annotation)
     {
         expect(transformation.getFieldAnnotation(fieldName, annotationClass)).andReturn(annotation);
     }
 
-    protected final void train_getFieldPersistenceStrategy(ComponentModel model, String fieldName,
-                                                           String fieldStrategy)
+    protected final void train_getFieldPersistenceStrategy(ComponentModel model, String fieldName,
String fieldStrategy)
     {
         expect(model.getFieldPersistenceStrategy(fieldName)).andReturn(fieldStrategy).atLeastOnce();
     }
 
-    protected final void train_getFieldType(ClassTransformation transformation, String fieldName,
-                                            String type)
+    protected final void train_getFieldType(ClassTransformation transformation, String fieldName,
String type)
     {
         expect(transformation.getFieldType(fieldName)).andReturn(type).atLeastOnce();
 
@@ -644,8 +628,7 @@
         expect(transformation.getMethodIdentifier(signature)).andReturn(id);
     }
 
-    protected final void train_getOutputStream(HttpServletResponse response,
-                                               ServletOutputStream stream)
+    protected final void train_getOutputStream(HttpServletResponse response, ServletOutputStream
stream)
     {
         try
         {
@@ -698,8 +681,7 @@
         expect(factory.getRootResource()).andReturn(rootResource);
     }
 
-    protected final void train_getSession(HttpServletRequest request, boolean create,
-                                          HttpSession session)
+    protected final void train_getSession(HttpServletRequest request, boolean create, HttpSession
session)
     {
         expect(request.getSession(create)).andReturn(session);
     }
@@ -714,8 +696,8 @@
         expect(model.getSupportsInformalParameters()).andReturn(supports);
     }
 
-    protected final void train_getValidationMessages(ValidationMessagesSource messagesSource,
-                                                     Locale locale, Messages messages)
+    protected final void train_getValidationMessages(ValidationMessagesSource messagesSource,
Locale locale,
+                                                     Messages messages)
     {
         expect(messagesSource.getValidationMessages(locale)).andReturn(messages).atLeastOnce();
     }
@@ -726,8 +708,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    protected final void train_handleResult(ComponentEventHandler handler, Object result,
-                                            Component component, String methodDescription,
boolean abort)
+    protected final void train_handleResult(ComponentEventHandler handler, Object result,
Component component,
+                                            String methodDescription, boolean abort)
     {
         expect(handler.handleResult(result, component, methodDescription)).andReturn(abort);
     }
@@ -762,35 +744,27 @@
         expect(parameter.name()).andReturn(name).atLeastOnce();
     }
 
-    protected final void train_newBinding(BindingFactory factory, String description,
-                                          ComponentResources container, ComponentResources
component, String expression,
-                                          Location l, Binding binding)
+    protected final void train_newBinding(BindingFactory factory, String description, ComponentResources
container,
+                                          ComponentResources component, String expression,
Location l, Binding binding)
     {
-        expect(factory.newBinding(description, container, component, expression, l)).andReturn(
-                binding);
+        expect(factory.newBinding(description, container, component, expression, l)).andReturn(binding);
     }
 
     protected void train_newBinding(BindingSource bindingSource, String description,
                                     ComponentResources componentResources, String defaultBindingPrefix,
-                                    String expression,
-                                    Binding binding)
+                                    String expression, Binding binding)
     {
-        expect(
-                bindingSource.newBinding(
-                        description,
-                        componentResources,
-                        defaultBindingPrefix,
-                        expression)).andReturn(binding);
+        expect(bindingSource.newBinding(description, componentResources, defaultBindingPrefix,
expression)).andReturn(
+                binding);
     }
 
-    protected final void train_newMemberName(ClassTransformation transformation, String suggested,
-                                             String name)
+    protected final void train_newMemberName(ClassTransformation transformation, String suggested,
String name)
     {
         expect(transformation.newMemberName(suggested)).andReturn(name);
     }
 
-    protected final void train_newMemberName(ClassTransformation transformation, String prefix,
-                                             String baseName, String name)
+    protected final void train_newMemberName(ClassTransformation transformation, String prefix,
String baseName,
+                                             String name)
     {
         expect(transformation.newMemberName(prefix, baseName)).andReturn(name);
     }
@@ -805,9 +779,8 @@
         expect(env.peekRequired(type)).andReturn(value);
     }
 
-    protected final void train_provideInjection(InjectionProvider provider, String fieldName,
-                                                Class fieldType, ObjectLocator locator,
-                                                ClassTransformation transformation,
+    protected final void train_provideInjection(InjectionProvider provider, String fieldName,
Class fieldType,
+                                                ObjectLocator locator, ClassTransformation
transformation,
                                                 MutableComponentModel model, boolean result)
     {
         expect(provider.provideInjection(fieldName, fieldType, locator, transformation, model))
@@ -815,8 +788,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    protected final void train_renderInformalParameters(ComponentResources resources,
-                                                        final MarkupWriter writer, final
Object... informals)
+    protected final void train_renderInformalParameters(ComponentResources resources, final
MarkupWriter writer,
+                                                        final Object... informals)
     {
         resources.renderInformalParameters(writer);
         IAnswer answer = new IAnswer()
@@ -832,14 +805,13 @@
         getMocksControl().andAnswer(answer);
     }
 
-    protected final void train_requiresDigest(ResourceDigestGenerator generator, String path,
-                                              boolean requiresDigest)
+    protected final void train_requiresDigest(ResourceDigestGenerator generator, String path,
boolean requiresDigest)
     {
         expect(generator.requiresDigest(path)).andReturn(requiresDigest);
     }
 
-    protected final void train_service(RequestHandler handler, Request request, Response
response,
-                                       boolean result) throws IOException
+    protected final void train_service(RequestHandler handler, Request request, Response
response, boolean result)
+            throws IOException
     {
         expect(handler.service(request, response)).andReturn(result);
     }
@@ -854,14 +826,12 @@
         response.setContentType(contentType);
     }
 
-    protected final void train_setDateHeader(HttpServletResponse response, String headerName,
-                                             long date)
+    protected final void train_setDateHeader(HttpServletResponse response, String headerName,
long date)
     {
         response.setDateHeader(headerName, date);
     }
 
-    protected final void train_toClass(ClassTransformation transformation, String type,
-                                       Class classForType)
+    protected final void train_toClass(ClassTransformation transformation, String type, Class
classForType)
     {
         expect(transformation.toClass(type)).andReturn(classForType);
     }
@@ -871,8 +841,7 @@
         expect(asset.toClientURL()).andReturn(URL).atLeastOnce();
     }
 
-    protected final void train_toClientURL(ClasspathAssetAliasManager manager, String resourcePath,
-                                           String clientURL)
+    protected final void train_toClientURL(ClasspathAssetAliasManager manager, String resourcePath,
String clientURL)
     {
         expect(manager.toClientURL(resourcePath)).andReturn(clientURL);
     }
@@ -882,8 +851,7 @@
         expect(link.toRedirectURI()).andReturn(URI).atLeastOnce();
     }
 
-    protected final void train_toResourcePath(ClasspathAssetAliasManager manager, String
clientURL,
-                                              String resourcePath)
+    protected final void train_toResourcePath(ClasspathAssetAliasManager manager, String
clientURL, String resourcePath)
     {
         expect(manager.toResourcePath(clientURL)).andReturn(resourcePath).atLeastOnce();
     }
@@ -898,8 +866,8 @@
         expect(annotation.value()).andReturn(value).atLeastOnce();
     }
 
-    protected final void train_create(BeanModelSource source, Class beanClass,
-                                      boolean filterReadOnly, ComponentResources containerResources,
BeanModel model)
+    protected final void train_create(BeanModelSource source, Class beanClass, boolean filterReadOnly,
+                                      ComponentResources containerResources, BeanModel model)
     {
         expect(source.create(beanClass, filterReadOnly, containerResources)).andReturn(model);
     }
@@ -959,10 +927,8 @@
         {
             is = componentClass.getResourceAsStream(file);
 
-            if (is == null)
-                throw new RuntimeException(String.format(
-                        "Class %s does not have a message catalog.",
-                        componentClass.getName()));
+            if (is == null) throw new RuntimeException(
+                    String.format("Class %s does not have a message catalog.", componentClass.getName()));
 
             properties.load(is);
         }
@@ -981,6 +947,6 @@
             map.put(skey, properties.getProperty(skey));
         }
 
-        return new MapMessages(map);
+        return new MapMessages(Locale.ENGLISH, map);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImpl.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImpl.java
Tue Nov 13 14:01:22 2007
@@ -16,16 +16,19 @@
 
 import org.apache.tapestry.ioc.MessageFormatter;
 
-/**
- *
- */
+import java.util.Locale;
+
+
 public class MessageFormatterImpl implements MessageFormatter
 {
     private final String _format;
 
-    public MessageFormatterImpl(String format)
+    private final Locale _locale;
+
+    public MessageFormatterImpl(String format, Locale locale)
     {
         _format = format;
+        _locale = locale;
     }
 
     public String format(Object... args)
@@ -46,7 +49,7 @@
         // Might be tempting to create a Formatter object and just keep reusing it ... but
         // Formatters are not threadsafe.
 
-        return String.format(_format, args);
+        return String.format(_locale, _format, args);
     }
 
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessagesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessagesImpl.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessagesImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/util/MessagesImpl.java
Tue Nov 13 14:01:22 2007
@@ -44,16 +44,17 @@
         String className = forClass.getName();
         String stringsClassName = className.replaceAll("Messages$", "Strings");
 
-        ResourceBundle bundle = ResourceBundle.getBundle(
-                stringsClassName,
-                Locale.getDefault(),
-                forClass.getClassLoader());
+        Locale locale = Locale.getDefault();
 
-        return new MessagesImpl(bundle);
+        ResourceBundle bundle = ResourceBundle.getBundle(stringsClassName, locale, forClass.getClassLoader());
+
+        return new MessagesImpl(locale, bundle);
     }
 
-    public MessagesImpl(ResourceBundle bundle)
+    public MessagesImpl(Locale locale, ResourceBundle bundle)
     {
+        super(locale);
+
         // Our best (threadsafe) chance to determine all the available keys.
         Enumeration<String> e = bundle.getKeys();
         while (e.hasMoreElements())

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
Tue Nov 13 14:01:22 2007
@@ -21,6 +21,7 @@
 import org.apache.tapestry.ioc.internal.util.Invokable;
 import org.apache.tapestry.ioc.internal.util.MessageFormatterImpl;
 
+import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -36,6 +37,13 @@
      */
     private final Map<String, MessageFormatter> _cache = newCaseInsensitiveMap();
 
+    private final Locale _locale;
+
+    protected AbstractMessages(Locale locale)
+    {
+        _locale = locale;
+    }
+
     /**
      * Invoked to provide the value for a particular key. This may be invoked multiple times
even
      * for the same key. The implementation should <em>ignore the case of the key</em>.
@@ -45,6 +53,7 @@
      */
     protected abstract String valueForKey(String key);
 
+
     public boolean contains(String key)
     {
         return valueForKey(key) != null;
@@ -88,7 +97,7 @@
     {
         String format = get(key);
 
-        return new MessageFormatterImpl(format);
+        return new MessageFormatterImpl(format, _locale);
     }
 
     public String format(String key, Object... args)

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImplTest.java?rev=594663&r1=594662&r2=594663&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/util/MessageFormatterImplTest.java
Tue Nov 13 14:01:22 2007
@@ -21,7 +21,7 @@
 {
     private String run(String format, Object... args)
     {
-        return new MessageFormatterImpl(format).format(args);
+        return new MessageFormatterImpl(format, null).format(args);
     }
 
     @Test
@@ -29,9 +29,7 @@
     {
         assertEquals(run("Tapestry is %s.", "cool"), "Tapestry is cool.");
         assertEquals(run("Tapestry release #%d.", 5), "Tapestry release #5.");
-        assertEquals(
-                run("%s is %s at version %d.", "Tapestry", "cool", 5),
-                "Tapestry is cool at version 5.");
+        assertEquals(run("%s is %s at version %d.", "Tapestry", "cool", 5), "Tapestry is
cool at version 5.");
     }
 
     @Test
@@ -39,9 +37,7 @@
     {
         Throwable t = new RuntimeException("Just didn't feel right.");
 
-        assertEquals(
-                run("%s failed: %s", "Something", t),
-                "Something failed: Just didn't feel right.");
+        assertEquals(run("%s failed: %s", "Something", t), "Something failed: Just didn't
feel right.");
     }
 
     @Test
@@ -49,8 +45,6 @@
     {
         Throwable t = new NullPointerException();
 
-        assertEquals(
-                run("%s failed: %s", "Something", t),
-                "Something failed: java.lang.NullPointerException");
+        assertEquals(run("%s failed: %s", "Something", t), "Something failed: java.lang.NullPointerException");
     }
 }



Mime
View raw message