use of org.activityinfo.i18n.shared.ApplicationLocale in project activityinfo by bedatadriven.
the class AppBar method localeClick.
@UiHandler("localeButton")
void localeClick(ClickEvent e) {
if (localeMenu == null) {
localeMenu = new Menu();
for (final ApplicationLocale applicationLocale : ApplicationLocale.values()) {
CheckMenuItem menuItem = new CheckMenuItem(applicationLocale.getLocalizedName());
menuItem.setChecked(LocaleSwitcher.isCurrent(applicationLocale));
menuItem.setGroup("lang");
menuItem.setDirectionEstimated(false);
menuItem.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
LocaleSwitcher.switchLocale(applicationLocale);
}
});
localeMenu.add(menuItem);
}
localeMenu.add(new SeparatorMenuItem());
MenuItem preferenceItem = new MenuItem(I18N.CONSTANTS.language());
preferenceItem.setDirectionEstimated(false);
preferenceItem.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
eventBus.fireEvent(new NavigationEvent(NavigationHandler.NAVIGATION_REQUESTED, new UserProfilePage.State()));
}
});
localeMenu.add(preferenceItem);
}
localeMenu.show(localeButton.getElement(), "?");
}
use of org.activityinfo.i18n.shared.ApplicationLocale in project activityinfo by bedatadriven.
the class UserProfilePage method maybeShowSwitchLocaleLink.
private void maybeShowSwitchLocaleLink() {
ApplicationLocale preferredLocale = ApplicationLocale.fromCode(userProfile.getLocale());
if (!LocaleSwitcher.isCurrent(preferredLocale)) {
localeLink.setText(I18N.MESSAGES.switchToLanguageNow(preferredLocale.getLocalizedName()));
localeLink.setHref(LocaleSwitcher.localeUrl(preferredLocale));
localeLinkField.setVisible(true);
} else {
localeLinkField.setVisible(false);
}
}
Aggregations