* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
I18nManager i18nMgr = I18nManager.getInstance();
//
// Add default languages pulldown
Set<String> availableKeys = I18nModule.getAvailableLanguageKeys();
String[] defaultlangKeys = ArrayHelper.toArray(availableKeys);
String[] defaultLangValues = new String[defaultlangKeys.length];
for (int i = 0; i < defaultlangKeys.length; i++) {
String key = defaultlangKeys[i];
String explLang = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
String all = explLang;
if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
defaultLangValues[i] = all;
}
ArrayHelper.sort(defaultlangKeys, defaultLangValues, false, true, false);
String[] defaultLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(defaultlangKeys, "b_with_small_icon_left");
defaultLangSelection = uifactory.addDropdownSingleselect("configuration.defaultLangSelection", formLayout, defaultlangKeys,
defaultLangValues, defaultLangCssClasses);
defaultLangSelection.addActionListener(this, FormEvent.ONCHANGE);
// Enable the current default language
Locale defaultLocale = I18nModule.getDefaultLocale();
this.flc.contextPut("defaultLangKey", defaultLocale.toString());
defaultLangSelection.select(defaultLocale.toString(), true);
//
// Add enabled languages checkboxes
String[] availablelangKeys = ArrayHelper.toArray(availableKeys);
String[] availableValues = new String[availablelangKeys.length];
int referenceKeyCount = i18nMgr.countI18nItems(I18nModule.getFallbackLocale(), null, true);
for (int i = 0; i < availablelangKeys.length; i++) {
String key = availablelangKeys[i];
String explLang = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
String all = explLang;
if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
// count translation status
int keyCount = i18nMgr.countI18nItems(i18nMgr.getLocaleOrNull(key), null, true);
all += " <span class='b_translation_status'>" + (keyCount * 100 / referenceKeyCount) + "%</span>";
availableValues[i] = all;
}
ArrayHelper.sort(availablelangKeys, availableValues, false, true, false);
String[] availableLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(availablelangKeys, "b_with_small_icon_left");
enabledLangSelection = uifactory.addCheckboxesVertical("configuration.enabledLangSelection", null, formLayout, availablelangKeys,
availableValues, availableLangCssClasses, 2);
enabledLangSelection.addActionListener(this, FormEvent.ONCHANGE);
// Enable current enabled languages
for (String langKey : I18nModule.getEnabledLanguageKeys()) {