]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/LocaleUtils.java
Releasing
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / LocaleUtils.java
index 415a0954dff41d4526e39ccf5b8413c3b7573b79..a09bf5a934187a1b7e878d95fdfca89a1748cfc6 100644 (file)
@@ -4,7 +4,6 @@ import java.util.Locale;
 import java.util.ResourceBundle;
 
 import org.argeo.api.cms.CmsLog;
-import org.argeo.cms.auth.CurrentUser;
 
 /** Utilities simplifying the development of localization enums. */
 public class LocaleUtils {
@@ -59,9 +58,10 @@ public class LocaleUtils {
        /** Where the search for a message is actually performed. */
        public static String local(String key, Locale locale, String resource, ClassLoader classLoader) {
                ResourceBundle rb = ResourceBundle.getBundle(resource, locale, classLoader);
-               assert key.length() > 2;
-               if (isLocaleKey(key))
+               if (isLocaleKey(key)) {
+                       assert key.length() > 1;
                        key = key.substring(1);
+               }
                if (rb.containsKey(key))
                        return rb.getString(key);
                else // for simple cases, the key will actually be the English word
@@ -77,6 +77,8 @@ public class LocaleUtils {
 
        /** Lead transformation on the translated string. */
        public static String toLead(String raw, Locale locale) {
+               if ("".equals(raw))
+                       return "";
                return raw.substring(0, 1).toUpperCase(locale) + raw.substring(1);
        }