net.lightoze.gwt.i18n.server.ThreadLocalLocaleProvider 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.server;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Locale;
/**
* @author David Parish
*/
public class ThreadLocalLocaleProvider implements LocaleProvider {
private static final ThreadLocal> locale = new ThreadLocal>() {
@Override
protected Deque initialValue() {
return new LinkedList();
}
};
@Override
public Locale getLocale() {
return locale.get().peek();
}
public static void pushLocale(Locale l) {
locale.get().push(l);
}
public static void popLocale() {
locale.get().pop();
}
}