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

net.lightoze.gwt.i18n.LocaleFactoryProvider Maven / Gradle / Ivy

There is a newer version: 0.26
Show newest version
package net.lightoze.gwt.i18n;

import com.google.gwt.i18n.client.LocalizableResource;
import net.lightoze.gwt.i18n.server.LocaleProxy;

import java.util.Locale;
import java.util.Map;
import java.util.WeakHashMap;

public class LocaleFactoryProvider {

    public Map> createClassCache() {
        return new WeakHashMap>();
    }

    /**
     * Create the resource using the Locale provided. If the locale is null, the locale is retrieved from the
     * LocaleProvider in LocaleProxy.
     *
     * @param cls    localization interface class
     * @param     localization interface class
     * @param locale locale string
     * @return object implementing specified class
     */
    public  T create(Class cls, String locale) {
        Locale l = null;
        if (locale != null) {
            String[] parts = locale.split("_", 3);
            l = new Locale(
                    parts[0],
                    parts.length > 1 ? parts[1] : "",
                    parts.length > 2 ? parts[2] : ""
            );
        }
        return LocaleProxy.create(cls, l);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy