package nl.b3p.viewer.util;

import nl.b3p.viewer.config.app.Application;
import org.apache.commons.lang.LocaleUtils;

import java.util.Locale;
import java.util.ResourceBundle;

public class ResourceBundleProvider {

    private static final String VIEWER_RESOURCES_FILE = "ViewerResources";

    public static ResourceBundle getResourceBundle() {
        return ResourceBundle.getBundle(VIEWER_RESOURCES_FILE);
    }

    public static ResourceBundle getResourceBundle(Locale locale) {
        return getResourceBundle(locale, null);
    }

    public static ResourceBundle getResourceBundle(Locale locale, Application application) {
        if (application != null) {
            locale = LocaleUtils.toLocale(application.getLang());
        }
        return ResourceBundle.getBundle(VIEWER_RESOURCES_FILE, locale);
    }

}

@@ -286,16 +286,71 @@
 rces%22;%0A%0A
+    private static final String BASE_LANGUAGE = %22nl%22;%0A%0A
     publ
@@ -392,24 +392,24 @@
 eBundle() %7B%0A
-
         retu
@@ -794,16 +794,535 @@
       %7D%0A
+%0A        // The language of the base properties file is %22nl%22, but getBundle() %0A        // considers the property file for the system default locale before%0A        // returning the base name properties file. We want the base%0A        // properties when %22nl%22 language is requested. Specifying Locale.ROOT%0A        // makes getBundle() only consider the base name.%0A        if(BASE_LANGUAGE.equals(locale.getLanguage())) %7B%0A            return ResourceBundle.getBundle(VIEWER_RESOURCES_FILE, Locale.ROOT);%0A        %7D else %7B%0A    
         
@@ -1389,13 +1389,22 @@
 e);%0A    
+ 
+   %7D%0A    
 %7D
-%0A
 %0A%7D%0A

fix getting base locale bundle, fixes #1262