cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r427439 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java
Date Tue, 01 Aug 2006 04:10:52 GMT
Author: antonio
Date: Mon Jul 31 21:10:52 2006
New Revision: 427439

URL: http://svn.apache.org/viewvc?rev=427439&view=rev
Log:

<action dev="AG" type="fix" fixes-bug="COCOON-1758" due-to="Carlos Chávez" due-to-email="cchavez@agssa.net">
  Form locale never used in JXMacros.
</action>

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java?rev=427439&r1=427438&r2=427439&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/i18n/I18nUtils.java Mon
Jul 31 21:10:52 2006
@@ -52,23 +52,21 @@
 
     /**
      * Parses given locale string to Locale object. If the string is null
-     * then the given locale is returned.
+     * or empty then the given locale is returned.
      *
-     * @param localeString a string containing locale in
-     * <code>language_country_variant</code> format.
-     * @param defaultLocale returned if localeString is <code>null</code>
+     * @param localeString - a string containing locale in
+     *        <code>language_country_variant</code> format.
+     * @param defaultLocale - returned if localeString is <code>null</code>
+     *        or <code>""</code>
      */
     public static Locale parseLocale(String localeString, Locale defaultLocale) {
-        if (localeString != null) {
-            StringTokenizer st = new StringTokenizer(localeString,
-                                                     LOCALE_DELIMITER);
-            String l = st.hasMoreElements() ? st.nextToken()
-                                            : defaultLocale.getLanguage();
+        if (localeString != null && localeString.length() > 0) {
+            StringTokenizer st = new StringTokenizer(localeString, LOCALE_DELIMITER);
+            String l = st.hasMoreElements() ? st.nextToken() : defaultLocale.getLanguage();
             String c = st.hasMoreElements() ? st.nextToken() : "";
             String v = st.hasMoreElements() ? st.nextToken() : "";
             return new Locale(l, c, v);
         }
-
         return defaultLocale;
     }
 



Mime
View raw message