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/14 21:20:24 UTC

svn commit: r421992 - /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java

Author: agilliland
Date: Fri Jul 14 12:20:24 2006
New Revision: 421992

URL: http://svn.apache.org/viewvc?rev=421992&view=rev
Log:
add new heavyweight method which provides a Locale instance.  the instance returned is either based on the locale specified by the request, or the weblog default.


Modified:
    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/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=421992&r1=421991&r2=421992&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 Fri Jul 14 12:20:24 2006
@@ -18,11 +18,11 @@
 
 package org.apache.roller.ui.rendering.util;
 
+import java.util.Locale;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
-import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.WebsiteData;
@@ -53,6 +53,7 @@
     
     // heavyweight attributes
     private WebsiteData weblog = null;
+    private Locale localeInstance = null;
     
     
     public WeblogRequest() {}
@@ -187,6 +188,32 @@
 
     public void setWeblog(WebsiteData weblog) {
         this.weblog = weblog;
+    }
+    
+    
+    /**
+     * Get the Locale instance to be used for this request.
+     *
+     * The Locale is determined via these rules ...
+     *   1. if a locale is explicitly specified, then it is used
+     *   2. if no locale is specified, then use the weblog default locale
+     */
+    public Locale getLocaleInstance() {
+        
+        if(localeInstance == null && locale != null) {
+            String[] langCountry = locale.split("_");
+            if(langCountry.length == 2) {
+                localeInstance = new Locale(langCountry[0], langCountry[1]);
+            }
+        } else if(localeInstance == null) {
+            localeInstance = getWeblog().getLocaleInstance();
+        }
+        
+        return localeInstance;
+    }
+
+    public void setLocaleInstance(Locale localeInstance) {
+        this.localeInstance = localeInstance;
     }
     
 }