}
});
}
private void setupLocaleSelect() {
final SelectElement select = (SelectElement) Document.get().getElementById("lang");
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String locale : localeNames) {
if (!DEFAULT_LOCALE.equals(locale)) {
String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
OptionElement option = Document.get().createOptionElement();
option.setValue(locale);
option.setText(displayName);
select.add(option, null);
if (locale.equals(currentLocale)) {
select.setSelectedIndex(select.getLength() - 1);
}
}
}
EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {
@Override
public boolean onChange(ChangeEvent event, Element context) {
UrlBuilder builder = Location.createUrlBuilder().setParameter(
"locale", select.getValue());
Window.Location.replace(builder.buildString());
localeService.storeLocale(select.getValue());
return true;
}
});
}