Author: joerg Date: Sat Jan 29 11:11:03 2005 New Revision: 149061 URL: http://svn.apache.org/viewcvs?view=rev&rev=149061 Log: made the logic for bundle selection more obvious Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java?view=diff&rev=149061&p1=cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r1=149060&p2=cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java&r2=149061 ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java Sat Jan 29 11:11:03 2005 @@ -254,33 +254,27 @@ synchronized (this) { bundle = selectCached(fileName); if (bundle == null) { + boolean localeAvailable = (locale != null && !locale.getLanguage().equals("")); + index++; XMLResourceBundle parentBundle = null; - if (locale != null && !locale.getLanguage().equals("")) { - if (++index == directories.length) - { - parentBundle = _select(directories, 0, name, getParentLocale(locale)); - } - else - { - parentBundle = _select(directories, index, name, locale); - } - } else if (++index < directories.length) { + if (localeAvailable && index == directories.length) { + // all directories have been searched with this locale, + // now start again with the first directory and the parent locale + parentBundle = _select(directories, 0, name, getParentLocale(locale)); + } else if (index < directories.length) { + // there are directories left to search for with this locale parentBundle = _select(directories, index, name, locale); } - if (!isNotFoundBundle(fileName)) { bundle = _loadBundle(name, fileName, locale, parentBundle); - updateCache(fileName, bundle); } - if (bundle == null) { return parentBundle; } } } } - return bundle; }
