hlship      2005/08/06 09:21:46

  Modified:    .        status.xml
               framework/src/test/org/apache/tapestry/junit
                        TestComponentMessages.java Library.properties
                        Library_fr.properties
               framework/src/java/org/apache/tapestry/services/impl
                        ComponentMessagesSourceImpl.java
  Log:
  TAPESTRY-530: Namespace messages are retrieved using page's locale rather 
than engine's locale
  
  Revision  Changes    Path
  1.189     +3 -2      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.188
  retrieving revision 1.189
  diff -u -r1.188 -r1.189
  --- status.xml        6 Aug 2005 16:07:29 -0000       1.188
  +++ status.xml        6 Aug 2005 16:21:46 -0000       1.189
  @@ -1,4 +1,4 @@
  -<?xml version="1.0"?>
  +  <?xml version="1.0"?>
   <!-- 
      Copyright 2005 The Apache Software Foundation
   
  @@ -69,8 +69,9 @@
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-519" due-to="Raphael 
Jean">NestedMarkupWriterImpl doesn't close the current open tag when 
getBuffer() is called</action>
         <action type="fix" dev="PF" fixes-bug="TAPESTRY-407">Unable to 
override default pattern of DateTranslator and NumberTranslator when 
initialized via the translator binding.</action>
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-529">Provide 
application: prefix to reference the application (root) namespace (from a 
library)</action>   
  -      <action type="update" dev="HLS">Enable Eclipse project-specific 
compile options, active additional checks as errors, and fix those errors in 
the code base.</action> 
  +      <action type="update" dev="HLS">Enable Eclipse project-specific 
compile options, active additional checks as errors, and fix those errors in 
the code base</action> 
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-534">WebRequest 
interface doesn't expose getRemoteUser(), isUserInRole() or 
getUserPrincipal()</action>
  +      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-530" due-to="Raphael 
Jean">Namespace messages are retrieved using page's locale rather than engine's 
locale</action>
       </release>
       <release version="4.0-beta-3" date="Jul 22 2005">
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-398" due-to="Jonas 
Maurus">HiveMind configuration error breaks the useage of the state: binding 
prefix</action>
  
  
  
  1.15      +21 -0     
jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java
  
  Index: TestComponentMessages.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestComponentMessages.java        27 Jul 2005 22:24:49 -0000      1.14
  +++ TestComponentMessages.java        6 Aug 2005 16:21:46 -0000       1.15
  @@ -292,4 +292,25 @@
           assertEquals("A formatted date: 24/12/66", 
messages.format("using-date-format", d));
   
       }
  +
  +    public void testMultipleLocalesWithNamespace()
  +    {
  +        ComponentMessagesSourceImpl source = new 
ComponentMessagesSourceImpl();
  +        source.setComponentPropertySource(new NullComponentPropertySource());
  +
  +        IComponentSpecification spec = newSpec(MOCK1);
  +        spec.setLocation(new CreatorLocation());
  +
  +        INamespace namespace = new Namespace(null, null, newLibrarySpec(), 
null, null);
  +
  +        IPage page = newPage(spec, source, new Locale("fr"));
  +        page.setNamespace(namespace);
  +        
  +        assertEquals("multilocale_fr", 
source.getMessages(page).getMessage("multilocale"));
  +        
  +        page = newPage(spec, source, new Locale("en"));
  +        page.setNamespace(namespace);
  +
  +        assertEquals("multilocale", 
source.getMessages(page).getMessage("multilocale"));
  +    }
   }
  \ No newline at end of file
  
  
  
  1.2       +2 -1      
jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/Library.properties
  
  Index: Library.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/Library.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Library.properties        6 Feb 2005 20:36:13 -0000       1.1
  +++ Library.properties        6 Aug 2005 16:21:46 -0000       1.2
  @@ -14,4 +14,5 @@
   
   only-in-namespace=LIBRARY_BASE.only-in-namespace
   
  -component-overrides-namespace=LIBRARY_BASE.component-overrides-namespace
  \ No newline at end of file
  +component-overrides-namespace=LIBRARY_BASE.component-overrides-namespace
  +multilocale=multilocale
  
  
  
  1.2       +2 -1      
jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/Library_fr.properties
  
  Index: Library_fr.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/Library_fr.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Library_fr.properties     6 Feb 2005 20:36:13 -0000       1.1
  +++ Library_fr.properties     6 Aug 2005 16:21:46 -0000       1.2
  @@ -13,4 +13,5 @@
   # limitations under the License.
   
   localized-in-namespace=LIBRARY_FR.localized-in-namespace
  
-localized-component-overrides-namespace=LIBRARY_FR.localized-component-overrides-namespace
  \ No newline at end of file
  
+localized-component-overrides-namespace=LIBRARY_FR.localized-component-overrides-namespace
  +multilocale=multilocale_fr
  
  
  
  1.11      +26 -12    
jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
  
  Index: ComponentMessagesSourceImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ComponentMessagesSourceImpl.java  8 Feb 2005 16:00:50 -0000       1.10
  +++ ComponentMessagesSourceImpl.java  6 Aug 2005 16:21:46 -0000       1.11
  @@ -139,8 +139,9 @@
       {
           List localizations = 
findLocalizationsForResource(baseResourceLocation, locale);
   
  -        Properties parent = getNamespaceProperties(component, locale);
  -
  +        Properties parent = null;
  +        Properties assembledProperties = null;
  +        
           Iterator i = localizations.iterator();
   
           while (i.hasNext())
  @@ -149,19 +150,32 @@
   
               Locale l = rl.getLocale();
   
  -            Properties properties = (Properties) propertiesMap.get(l);
  -
  -            if (properties == null)
  -            {
  -                properties = readComponentProperties(component, l, 
rl.getResource(), parent);
  -
  -                propertiesMap.put(l, properties);
  +            // Retrieve namespace properties for current locale (and parent 
locales)
  +             Properties namespaceProperties = 
getNamespaceProperties(component, l);
  +             
  +             // Use the namespace properties as default for assembled 
properties
  +            assembledProperties = new Properties(namespaceProperties);
  +            
  +            // Read localized properties for component
  +            Properties properties = readComponentProperties(component, l, 
rl.getResource(), null);
  +
  +            // Override parent properties with current locale
  +            if (parent != null) {
  +             if (properties != null)
  +                     parent.putAll(properties);
               }
  -
  -            parent = properties;
  +            else
  +             parent = properties;
  +            
  +            // Add to assembled properties
  +            if (parent != null)
  +             assembledProperties.putAll(parent);
  +            
  +            // Save result in cache
  +            propertiesMap.put(l, assembledProperties);
           }
   
  -        return parent;
  +        return assembledProperties;
       }
   
       private Properties assembleNamespaceProperties(INamespace namespace, Map 
propertiesMap,
  
  
  

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

Reply via email to