@Override
  protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    super.formInnerEvent(ureq, source, event);
    if (source == cancelButton) {
      fireEvent(ureq, Event.CANCELLED_EVENT);

    } else if (source == importFile) {
      if (importFile.isUploadSuccess()) {
        File tmpJar = importFile.getUploadFile();
        Set<String> importLangKeys =
            I18nManager.getInstance().sarchForAvailableLanguagesInJarFile(tmpJar, true);
        if (importLangKeys.size() == 0) {
          showError("configuration.management.package.import.failure.empty");
          return;
        }
        //
        // enable language key selection
        String[] langKeys = ArrayHelper.toArray(importLangKeys);
        importKeys.setKeysAndValues(langKeys, langKeys);
        importKeys.selectAll();
        importKeys.setVisible(true);
        // In language adaption mode the import is done as a package - can't deselect anything
        importKeys.setEnabled(false);
      }
    }
  }
예제 #2
0
 public Languages getLanguages() {
   I18nManager i18nMgr = I18nManager.getInstance();
   Collection<String> enabledKeysSet = I18nModule.getEnabledLanguageKeys();
   Map<String, String> langNames = new HashMap<String, String>();
   Map<String, String> langTranslators = new HashMap<String, String>();
   String[] enabledKeys = ArrayHelper.toArray(enabledKeysSet);
   String[] names = new String[enabledKeys.length];
   for (int i = 0; i < enabledKeys.length; i++) {
     String key = enabledKeys[i];
     String langName = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
     langNames.put(key, langName);
     names[i] = langName;
     String author = i18nMgr.getLanguageAuthor(key);
     langTranslators.put(key, author);
   }
   ArrayHelper.sort(enabledKeys, names, true, true, true);
   return new Languages(enabledKeys, langNames, langTranslators);
 }