FELIX-2029 Properly handle the default locale both for placing it at the root of the Locale chain and for keeping it in the resource bundle entries map. Also ensure, that entires may not be overwritten by fragments.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@905638 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java
index 6ac874f..44d89a9 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java
@@ -134,7 +134,17 @@
                     final int end = entryPath.length() - 11; // .properties suffix
                     entryPath = entryPath.substring( start, end );
 
-                    resourceBundleEntries.put( entryPath, entry );
+                    // the default language is "name.properties" thus the entry
+                    // path is empty and must default to "_"
+                    if (entryPath.length() == 0) {
+                        entryPath = "_";
+                    }
+
+                    // only add this entry, if the "language" is not provided
+                    // by the main bundle or an earlier bound fragment
+                    if (!resourceBundleEntries.containsKey( entryPath )) {
+                        resourceBundleEntries.put( entryPath, entry );
+                    }
                 }
             }
 
@@ -155,7 +165,7 @@
         {
             return new Locale( locale.getLanguage() );
         }
-        else if ( locale.getLanguage().equals( DEFAULT_LOCALE.getLanguage() ) )
+        else if ( !locale.getLanguage().equals( DEFAULT_LOCALE.getLanguage() ) )
         {
             return DEFAULT_LOCALE;
         }