manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1224937 - in /incubator/lcf/branches/CONNECTORS-335/framework: core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java crawler-ui/src/main/webapp/adminDefaults.jsp crawler-ui/src/main/webapp/adminHeaders.jsp
Date Tue, 27 Dec 2011 15:57:47 GMT
Author: kwright
Date: Tue Dec 27 15:57:46 2011
New Revision: 1224937

URL: http://svn.apache.org/viewvc?rev=1224937&view=rev
Log:
Build in escalation path that includes language-only locales.

Modified:
    incubator/lcf/branches/CONNECTORS-335/framework/core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java
    incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
    incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminHeaders.jsp

Modified: incubator/lcf/branches/CONNECTORS-335/framework/core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-335/framework/core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java?rev=1224937&r1=1224936&r2=1224937&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-335/framework/core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java
(original)
+++ incubator/lcf/branches/CONNECTORS-335/framework/core/src/main/java/org/apache/manifoldcf/core/i18n/Messages.java
Tue Dec 27 15:57:46 2011
@@ -49,16 +49,6 @@ public class Messages
   // These four have limited applicability since they are all local to the core jar, which
generally does not render
   // text.
   
-  public static String getString(String messageKey)
-  {
-    return getString(DEFAULT_BUNDLE_NAME, Locale.getDefault(), messageKey, null);
-  }
-  
-  public static String getString(String messageKey, Object[] args)
-  {
-    return getString(DEFAULT_BUNDLE_NAME, Locale.getDefault(), messageKey, args);
-  }
-  
   public static String getString(Locale locale, String messageKey)
   {
     return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
@@ -71,26 +61,6 @@ public class Messages
   
   // More general methods which allow bundlenames and class loaders to be specified.
   
-  public static String getString(String bundleName, String messageKey)
-  {
-    return getString(bundleName, Locale.getDefault(), messageKey, null);
-  }
-
-  public static String getString(ClassLoader classLoader, String bundleName, String messageKey)
-  {
-    return getString(classLoader, bundleName, Locale.getDefault(), messageKey, null);
-  }
-  
-  public static String getString(String bundleName, String messageKey, Object[] args)
-  {
-    return getString(bundleName, Locale.getDefault(), messageKey, args);
-  }
-
-  public static String getString(ClassLoader classLoader, String bundleName, String messageKey,
Object[] args)
-  {
-    return getString(classLoader, bundleName, Locale.getDefault(), messageKey, args);
-  }
-  
   public static String getString(String bundleName, Locale locale, String messageKey)
   {
     return getString(bundleName, locale, messageKey, null);
@@ -117,9 +87,24 @@ public class Messages
     {
       complainMissingResource("No resource in path '"+pathName+"' named '"+resourceKey+"'
found for locale '"+locale.toString()+"'",
         new Exception("Resource not found"),pathName,locale,resourceKey);
-      is = classInstance.getResourceAsStream(localizeResourceName(pathName,resourceKey,Locale.US));
+      locale = new Locale(locale.getLanguage());
+      is = classInstance.getResourceAsStream(localizeResourceName(pathName,resourceKey,locale));
       if (is == null)
-        throw new ManifoldCFException("No backup resource in path '"+pathName+"' named '"+resourceKey+"'
found for US locale!");
+      {
+        complainMissingResource("No resource in path '"+pathName+"' named '"+resourceKey+"'
found for locale '"+locale.toString()+"'",
+          new Exception("Resource not found"),pathName,locale,resourceKey);
+        locale = Locale.US;
+        is = classInstance.getResourceAsStream(localizeResourceName(pathName,resourceKey,locale));
+        if (is == null)
+        {
+          complainMissingResource("No resource in path '"+pathName+"' named '"+resourceKey+"'
found for locale '"+locale.toString()+"'",
+            new Exception("Resource not found"),pathName,locale,resourceKey);
+          locale = new Locale(locale.getLanguage());
+          is = classInstance.getResourceAsStream(localizeResourceName(pathName,resourceKey,locale));
+          if (is == null)
+            throw new ManifoldCFException("No language resource in path '"+pathName+"' named
'"+resourceKey+"' found for locale '"+locale.toString()+"'");
+        }
+      }
     }
     return is;
   }
@@ -146,17 +131,38 @@ public class Messages
     }
     catch (MissingResourceException e)
     {
-      // Use English if we don't have a bundle for the current locale
-      complainMissingBundle("Missing resource bundle '" + bundleName + "' for locale '"+locale.toString()+"':
"+e.getMessage()+"; trying en_US",
+      complainMissingBundle("Missing resource bundle '" + bundleName + "' for locale '"+locale.toString()+"':
"+e.getMessage()+"; trying "+locale.getLanguage(),
         e,bundleName,locale);
+      // Try plain language next
+      locale = new Locale(locale.getLanguage());
       try
       {
-        resources = ResourceBundle.getBundle(bundleName, Locale.US, classLoader);
+        resources = ResourceBundle.getBundle(bundleName, locale, classLoader);
       }
       catch (MissingResourceException e2)
       {
-        complainMissingBundle("No backup US bundle found either! "+e.getMessage(),e,bundleName,Locale.US);
-        return messageKey;
+        // Use English if we don't have a bundle for the current locale
+        complainMissingBundle("Missing resource bundle '" + bundleName + "' for locale '"+locale.toString()+"':
"+e2.getMessage()+"; trying en_US",
+          e2,bundleName,locale);
+        locale = Locale.US;
+        try
+        {
+          resources = ResourceBundle.getBundle(bundleName, locale, classLoader);
+        }
+        catch (MissingResourceException e3)
+        {
+          complainMissingBundle("No backup en_US bundle found! "+e3.getMessage(),e3,bundleName,locale);
+          locale = new Locale(locale.getLanguage());
+          try
+          {
+            resources = ResourceBundle.getBundle(bundleName, locale, classLoader);
+          }
+          catch (MissingResourceException e4)
+          {
+            complainMissingBundle("No backup en bundle found! "+e4.getMessage(),e4,bundleName,locale);
+            return messageKey;
+          }
+        }
       }
     }
     

Modified: incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminDefaults.jsp?rev=1224937&r1=1224936&r2=1224937&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
(original)
+++ incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
Tue Dec 27 15:57:46 2011
@@ -1,6 +1,6 @@
 <%@ page language="java" %>
 <%@ page import="org.apache.manifoldcf.core.interfaces.*" %>
-<%@ page import="org.apache.manifoldcf.core.i18n.*" %>
+<%@ page import="org.apache.manifoldcf.ui.i18n.*" %>
 <%@ page import="org.apache.manifoldcf.agents.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.authorities.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.crawler.interfaces.*" %>

Modified: incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminHeaders.jsp?rev=1224937&r1=1224936&r2=1224937&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
(original)
+++ incubator/lcf/branches/CONNECTORS-335/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
Tue Dec 27 15:57:46 2011
@@ -30,7 +30,7 @@ response.setContentType("text/html;chars
 <%@ page language="java" %>
 <%@ page import="org.apache.manifoldcf.core.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.core.util.*" %>
-<%@ page import="org.apache.manifoldcf.core.i18n.*" %>
+<%@ page import="org.apache.manifoldcf.ui.i18n.*" %>
 <%@ page import="org.apache.manifoldcf.agents.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.crawler.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.authorities.interfaces.*" %>



Mime
View raw message