Author: scottbw
Date: Wed Jun  8 11:05:35 2011
New Revision: 1133342

URL: http://svn.apache.org/viewvc?rev=1133342&view=rev
Log:
Implemented DefaultLocale processing for folder-based localization - see 
WOOKIE-211. Whenever the server has a request for a resource, if no localized 
version is available for the specified user locale, and no non-localized 
resource is available, we now check for a resource using the Widget's 
defaultLocale attribute as a final resort.

Modified:
    
incubator/wookie/trunk/src/org/apache/wookie/server/LocalizedResourceFilter.java

Modified: 
incubator/wookie/trunk/src/org/apache/wookie/server/LocalizedResourceFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/server/LocalizedResourceFilter.java?rev=1133342&r1=1133341&r2=1133342&view=diff
==============================================================================
--- 
incubator/wookie/trunk/src/org/apache/wookie/server/LocalizedResourceFilter.java
 (original)
+++ 
incubator/wookie/trunk/src/org/apache/wookie/server/LocalizedResourceFilter.java
 Wed Jun  8 11:05:35 2011
@@ -169,6 +169,13 @@ public class LocalizedResourceFilter imp
 
                // All attempts to locate a localized copy have failed, so we 
must try to find a non-localized version instead
                if (new 
File(filterConfig.getServletContext().getRealPath(basePath)).exists()) return 
context+basePath;
+               
+               // As a last resort, we'll try defautLocale
+               if (instance.getWidget().getDefaultLocale() != null){
+                 String path = basePath.replace(resource, 
"locales/"+instance.getWidget().getDefaultLocale().toLowerCase()+"/"+resource);
+                 String filePath = 
filterConfig.getServletContext().getRealPath(path);         
+      if (new File(filePath).exists()) return context+path;
+               }
 
                // No localized or even non-localized file exists, so just 
return the original. This situation shouldn't arise except
                // where, e.g., the original request was for a non-existing 
resource


Reply via email to