You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/07/17 23:29:23 UTC

svn commit: r422884 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller: business/hibernate/HibernateWeblogManagerImpl.java ui/rendering/WeblogRequestMapper.java ui/rendering/util/WeblogRequest.java

Author: agilliland
Date: Mon Jul 17 14:29:22 2006
New Revision: 422884

URL: http://svn.apache.org/viewvc?rev=422884&view=rev
Log:
support both 2 char and 5 char locale strings for new multi-lang blogging feature.


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=422884&r1=422883&r2=422884&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java Mon Jul 17 14:29:22 2006
@@ -316,7 +316,7 @@
         }
         
         if(locale != null) {
-            conjunction.add(Expression.eq("locale", locale));
+            conjunction.add(Expression.ilike("locale", locale, MatchMode.START));
         }
         
         try {
@@ -450,7 +450,7 @@
             }
             
             if (locale != null) {
-                criteria.add(Expression.eq("locale", locale));
+                criteria.add(Expression.ilike("locale", locale, MatchMode.START));
             }
             
             if (sortby != null && sortby.equals("updateTime")) {

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java?rev=422884&r1=422883&r2=422884&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java Mon Jul 17 14:29:22 2006
@@ -338,13 +338,18 @@
         
         boolean isLocale = false;
         
-        // we only support 5 character locale strings, so check that first
-        if(potentialLocale != null && potentialLocale.length() == 5) {
+        // we only support 2 or 5 character locale strings, so check that first
+        if(potentialLocale != null && 
+                (potentialLocale.length() == 2 || potentialLocale.length() == 5)) {
             
             // now make sure that the format is proper ... e.g. "en_US"
             // we are not going to be picky about capitalization
             String[] langCountry = potentialLocale.split("_");
-            if(langCountry.length == 2 && 
+            if(langCountry.length == 1 && 
+                    langCountry[0] != null && langCountry[0].length() == 2) {
+                isLocale = true;
+                
+            } else if(langCountry.length == 2 && 
                     langCountry[0] != null && langCountry[0].length() == 2 && 
                     langCountry[1] != null && langCountry[1].length() == 2) {
                 

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java?rev=422884&r1=422883&r2=422884&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java Mon Jul 17 14:29:22 2006
@@ -130,13 +130,18 @@
         
         boolean isLocale = false;
         
-        // we only support 5 character locale strings, so check that first
-        if(potentialLocale != null && potentialLocale.length() == 5) {
+        // we only support 2 or 5 character locale strings, so check that first
+        if(potentialLocale != null && 
+                (potentialLocale.length() == 2 || potentialLocale.length() == 5)) {
             
             // now make sure that the format is proper ... e.g. "en_US"
             // we are not going to be picky about capitalization
             String[] langCountry = potentialLocale.split("_");
-            if(langCountry.length == 2 && 
+            if(langCountry.length == 1 && 
+                    langCountry[0] != null && langCountry[0].length() == 2) {
+                isLocale = true;
+                
+            } else if(langCountry.length == 2 && 
                     langCountry[0] != null && langCountry[0].length() == 2 && 
                     langCountry[1] != null && langCountry[1].length() == 2) {
                 
@@ -202,7 +207,9 @@
         
         if(localeInstance == null && locale != null) {
             String[] langCountry = locale.split("_");
-            if(langCountry.length == 2) {
+            if(langCountry.length == 1) {
+                localeInstance = new Locale(langCountry[0]);
+            } else if(langCountry.length == 2) {
                 localeInstance = new Locale(langCountry[0], langCountry[1]);
             }
         } else if(localeInstance == null) {