private int getLocaleIndex(String localeKey) { List<Locale> locales = Context.getLocales(); assert (locales != null); for (int index = 0; index < locales.size(); index++) { Locale locale = locales.get(index); if (locale.getKey().equals(localeKey)) return index; } return 0; }
/** Populates the locale drop down with a list of locales supported by the form designer. */ public void populateLocales() { cbLanguages.clear(); List<Locale> locales = Context.getLocales(); if (locales == null) return; for (Locale locale : locales) cbLanguages.addItem(locale.getName(), locale.getKey()); Locale locale = Context.getLocale(); if (locale != null) cbLanguages.setSelectedIndex(getLocaleIndex(locale.getKey())); }