@Override protected void formOK(UserRequest ureq) { if (importKeys.isVisible() && importKeys.getSelectedKeys().size() > 0) { Collection<String> importLangKeys = importKeys.getSelectedKeys(); Set<String> alreadyInstalledLangs = new HashSet<String>(); for (String langKey : importLangKeys) { if (I18nModule.getAvailableLanguageKeys().contains(langKey)) { alreadyInstalledLangs.add(langKey); } } if (I18nModule.isTransToolEnabled()) { // In translation mode importing will copy the language package // over an existing language or create a new language File tmpJar = importFile.getUploadFile(); I18nManager.getInstance().copyLanguagesFromJar(tmpJar, importLangKeys); logAudit("Uploaded languages from jar::" + importFile.getUploadFileName(), null); showInfo("configuration.management.package.import.success", importLangKeys.toString()); } else { // In language adaption mode: import is copied to user managed i18n package space in // olatdata if (alreadyInstalledLangs.size() == importLangKeys.size()) { showError("configuration.management.package.import.failure.installed"); return; } // Ok, contains at least one language, copy to lang pack dir importFile.moveUploadFileTo(I18nModule.LANG_PACKS_DIRECTORY); logAudit("Uploaded language pack::" + importFile.getUploadFileName(), null); if (alreadyInstalledLangs.size() > 0) { getWindowControl() .setWarning( getTranslator() .translate( "configuration.management.package.import.success.with.existing", new String[] { importLangKeys.toString(), alreadyInstalledLangs.toString() })); } else { showInfo("configuration.management.package.import.success", importLangKeys.toString()); } } // Reset i18n system I18nModule.reInitializeAndFlushCache(); fireEvent(ureq, Event.DONE_EVENT); } }
/** * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event) */ @Override public void event(UserRequest ureq, Controller source, Event event) { if (source == dialogCtr) { if (DialogBoxUIFactory.isYesEvent(event)) { // Yes case, delete now for (String deleteLangPack : deleteLangPackSelection.getSelectedKeys()) { File file = new File(I18nModule.LANG_PACKS_DIRECTORY, deleteLangPack); if (file.exists()) file.delete(); logAudit("Deleted language pack::" + deleteLangPack, null); } // Reset i18n system I18nModule.reInitializeAndFlushCache(); // wow, everything worked fine showInfo( "configuration.management.package.delete.success", deleteLangPackSelection.getSelectedKeys().toString()); fireEvent(ureq, Event.DONE_EVENT); } else { // No case, do nothing. } } }