incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1378095 - /sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
Date Tue, 28 Aug 2012 12:01:21 GMT
Author: cziegeler
Date: Tue Aug 28 12:01:21 2012
New Revision: 1378095

URL: http://svn.apache.org/viewvc?rev=1378095&view=rev
Log:
SLING-2576 : I18n: Allow multiple ResourceBundleProviders, use the first one responding for
a given locale

Modified:
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java?rev=1378095&r1=1378094&r2=1378095&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
Tue Aug 28 12:01:21 2012
@@ -179,7 +179,9 @@ public class I18NFilter implements Filte
 
         public Locale getDefaultLocale() {
             // ask all registered providers, use the first one that returns
-            for (final ResourceBundleProvider provider : sortedProviders) {
+            final ResourceBundleProvider[] providers = sortedProviders;
+            for(int i=providers.length-1; i >= 0; i--) {
+                final ResourceBundleProvider provider = providers[i];
                 final Locale locale = provider.getDefaultLocale();
                 if (locale != null) {
                     return locale;
@@ -190,7 +192,9 @@ public class I18NFilter implements Filte
 
         public ResourceBundle getResourceBundle(final Locale locale) {
             // ask all registered providers, use the first one that returns
-            for (final ResourceBundleProvider provider : sortedProviders) {
+            final ResourceBundleProvider[] providers = sortedProviders;
+            for(int i=providers.length-1; i >= 0; i--) {
+                final ResourceBundleProvider provider = providers[i];
                 final ResourceBundle bundle = provider.getResourceBundle(locale);
                 if (bundle != null) {
                     return bundle;
@@ -201,7 +205,9 @@ public class I18NFilter implements Filte
 
         public ResourceBundle getResourceBundle(final String baseName, final Locale locale)
{
             // ask all registered providers, use the first one that returns
-            for (final ResourceBundleProvider provider : sortedProviders) {
+            final ResourceBundleProvider[] providers = sortedProviders;
+            for(int i=providers.length-1; i >= 0; i--) {
+                final ResourceBundleProvider provider = providers[i];
                 final ResourceBundle bundle = provider.getResourceBundle(baseName, locale);
                 if (bundle != null) {
                     return bundle;



Mime
View raw message