final Image imageI18n = new Image();
horizontalPanel_1.add(imageI18n);
imageI18n.setSize("16", "16");
imageI18n.setUrl("images/locale.png");
final ListBox listBoxLocale = new ListBox();
horizontalPanel_1.add(listBoxLocale);
// listBoxLocale.setTabIndex(1);
listBoxLocale.setWidth("15em");
// listBoxLocale.setEnabled(false);
// // Map to location in list.
HashMap<String, Integer> localeMap = new HashMap<String, Integer>();
int i = 0;
/**
* Two letter codes are taken by ISO 639-1 specs at:
* http://www.sil.org/iso639-3/codes.asp?order=639_1
*/
localeMap.put("de", i++);
localeMap.put("en", i++);
localeMap.put("es", i++);
localeMap.put("fr", i++);
localeMap.put("it", i++);
localeMap.put("ja", i++);
localeMap.put("nl", i++);
localeMap.put("pt", i++);
localeMap.put("ru", i++);
localeMap.put("zh", i++);
listBoxLocale.addItem("Deutsch", "de");
listBoxLocale.addItem("English", "en");
listBoxLocale.addItem("Español", "es");
listBoxLocale.addItem("Français", "fr");
listBoxLocale.addItem("Italiano", "it");
listBoxLocale.addItem("日本語", "ja");
listBoxLocale.addItem("Nederlands", "nl");
listBoxLocale.addItem("Português", "pt");
listBoxLocale.addItem("Русский", "ru");
listBoxLocale.addItem("中文", "zh");
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
if (currentLocale.equals("default")) {
currentLocale = "en";
}
// GenClient.showDebug("localeMap: " + localeMap);
// GenClient.showDebug("currentLocale: " + currentLocale);
int idx = localeMap.get(currentLocale);
if (idx < 0) {
idx = 1; // en is default
}
listBoxLocale.setSelectedIndex(idx);
listBoxLocale.addChangeListener(new ChangeListener() {
public void onChange(Widget sender) {
String localeName = listBoxLocale.getValue(listBoxLocale.getSelectedIndex());
// original method.
// Window.open(UtilsJS.getHostPageLocation() + "?locale="
// + localeName, "_self", "");
String windowLocationOrg = UtilsJS.getHostPageLocation() + "?locale=" + localeName;