incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1146778 - in /sling/trunk/contrib/extensions/i18n/src: main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
Date Thu, 14 Jul 2011 16:14:01 GMT
Author: justin
Date: Thu Jul 14 16:14:00 2011
New Revision: 1146778

URL: http://svn.apache.org/viewvc?rev=1146778&view=rev
Log:
SLING-2121 - querying for jcr:language property using fn:lower-case

Modified:
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
    sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java?rev=1146778&r1=1146777&r2=1146778&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
Thu Jul 14 16:14:00 2011
@@ -152,18 +152,18 @@ public class JcrResourceBundle extends R
 
         buf.append("//element(*,mix:language)[");
 
-        String localeString = locale.toString();
-        String localeRFC4646String = toRFC4646String(locale);
+        String localeString = locale.toString().toLowerCase();
+        String localeRFC4646String = toRFC4646String(locale).toLowerCase();
 
         if (localeString.equals(localeRFC4646String)) {
-            buf.append("@jcr:language='");
+            buf.append("fn:lower-case(@jcr:language)='");
             buf.append(localeString);
             buf.append('\'');
         } else {
-            buf.append("(@jcr:language='");
+            buf.append("(fn:lower-case(@jcr:language)='");
             buf.append(localeString);
             buf.append('\'');
-            buf.append(" or @jcr:language='");
+            buf.append(" or fn:lower-case(@jcr:language)='");
             buf.append(localeRFC4646String);
             buf.append("\')");
         }

Modified: sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java?rev=1146778&r1=1146777&r2=1146778&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
Thu Jul 14 16:14:00 2011
@@ -246,6 +246,7 @@ public class JcrResourceBundleTest exten
     public static final Map<String, Message> MESSAGES_EN = new LinkedHashMap<String,
Message>();
     public static final Map<String, Message> MESSAGES_EN_DASH_US = new LinkedHashMap<String,
Message>();
     public static final Map<String, Message> MESSAGES_EN_UNDERSCORE_UK = new LinkedHashMap<String,
Message>();
+    public static final Map<String, Message> MESSAGES_EN_UNDERSCORE_AU = new LinkedHashMap<String,
Message>();
     public static final Map<String, Message> MESSAGES_DE_APPS = new LinkedHashMap<String,
Message>();
     public static final Map<String, Message> MESSAGES_DE_BASENAME = new LinkedHashMap<String,
Message>();
 
@@ -271,6 +272,7 @@ public class JcrResourceBundleTest exten
 
         add(MESSAGES_EN_DASH_US, new Message("", "pigment", "color", false));
         add(MESSAGES_EN_UNDERSCORE_UK, new Message("", "pigment", "colour", false));
+        add(MESSAGES_EN_UNDERSCORE_AU, new Message("", "pigment", "colour", false));
 
         // 6. same as 1.-4., but different translations for overwriting into apps
         for (Message msg : MESSAGES_DE.values()) {
@@ -313,7 +315,7 @@ public class JcrResourceBundleTest exten
         }
         getSession().save();
 
-        // some EN US content
+        // some EN UK content
         Node enUnderscoreUK = i18n.addNode("en_UK", "nt:folder");
         enUnderscoreUK.addMixin("mix:language");
         enUnderscoreUK.setProperty("jcr:language", "en_UK");
@@ -321,6 +323,15 @@ public class JcrResourceBundleTest exten
             msg.add(enUnderscoreUK);
         }
         getSession().save();
+
+        // some EN AU content
+        Node enUnderscoreAU = i18n.addNode("en_au", "nt:folder");
+        enUnderscoreAU.addMixin("mix:language");
+        enUnderscoreAU.setProperty("jcr:language", "en_au");
+        for (Message msg : MESSAGES_EN_UNDERSCORE_AU.values()) {
+            msg.add(enUnderscoreAU);
+        }
+        getSession().save();
     }
 
     // ---------------------------------------------------------------< tests >
@@ -340,6 +351,11 @@ public class JcrResourceBundleTest exten
         for (Message msg : MESSAGES_EN_UNDERSCORE_UK.values()) {
             assertEquals(msg.message, bundle.getString(msg.key));
         }
+        
+        bundle = new JcrResourceBundle(new Locale("en", "au"), null, resolver);
+        for (Message msg : MESSAGES_EN_UNDERSCORE_AU.values()) {
+            assertEquals(msg.message, bundle.getString(msg.key));
+        }
     }
 
     public void test_getObject() {



Mime
View raw message