net.lightoze.gwt.i18n.LocaleFactoryProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-i18n-server Show documentation
Show all versions of gwt-i18n-server Show documentation
A project to make GWT localization available on server side.
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);
}
}