All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dps.webapplication.i18n.ResourceBundles Maven / Gradle / Ivy

There is a newer version: 1.2.5
Show newest version
package dps.webapplication.i18n;

import javax.enterprise.context.ApplicationScoped;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

@ApplicationScoped
public class ResourceBundles {

    Map> resourceBundles = new HashMap<>();

    ResourceBundle getBundle(Locale locale, String name)
    {
        ResourceBundle bundle = null;
        Map resourceBundlesMap = resourceBundles.get(locale);
        if (resourceBundlesMap == null) {
            resourceBundlesMap = new HashMap<>();
            resourceBundles.put(locale,resourceBundlesMap);
        } else {
            bundle = resourceBundlesMap.get(name);
        }
        if (bundle == null) {
            bundle = ResourceBundle.getBundle(name, locale);
            resourceBundlesMap.put(name,bundle);
        }
        return bundle;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy