Search in sources :

Example 46 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class LTICourseNodeConfiguration method getLinkText.

@Override
public String getLinkText(Locale locale) {
    Translator fallback = Util.createPackageTranslator(CourseNodeConfiguration.class, locale);
    Translator translator = Util.createPackageTranslator(this.getClass(), locale, fallback);
    return translator.translate("title_lti");
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Example 47 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class OperatorManager method getRegisteredAndAlreadyTranslatedOperatorLabels.

public static String[] getRegisteredAndAlreadyTranslatedOperatorLabels(Locale locale, String[] operatorKeys) {
    List<String> keys = Arrays.asList(operatorKeys);
    Translator t = new PackageTranslator(OperatorManager.class.getPackage().getName(), locale);
    String[] tmp = new String[operatorKeys.length];
    int i = 0;
    for (Operator o : ops) {
        if (keys.contains(o.getOperatorKey())) {
            tmp[i++] = t.translate(o.getLabelKey());
        }
    }
    return tmp;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 48 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class COCourseNode method createNodeRunConstructionResult.

/**
 * @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.course.run.userview.NodeEvaluation)
 */
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller controller;
    // Do not allow guests to send anonymous emails
    Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
        Translator trans = Util.createPackageTranslator(COCourseNode.class, ureq.getLocale());
        String title = trans.translate("guestnoaccess.title");
        String message = trans.translate("guestnoaccess.message");
        controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else if (userCourseEnv.isCourseReadOnly()) {
        Translator trans = Util.createPackageTranslator(COCourseNode.class, ureq.getLocale());
        String title = trans.translate("freezenoaccess.title");
        String message = trans.translate("freezenoaccess.message");
        controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
        controller = new CORunController(getModuleConfiguration(), ureq, wControl, userCourseEnv);
    }
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_co_icon");
    return new NodeRunConstructionResult(ctrl);
}
Also used : CORunController(org.olat.course.nodes.co.CORunController) Translator(org.olat.core.gui.translator.Translator) Roles(org.olat.core.id.Roles) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) CORunController(org.olat.course.nodes.co.CORunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) COEditController(org.olat.course.nodes.co.COEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 49 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class QTIExportManager method selectAndExportResults.

public boolean selectAndExportResults(QTIExportFormatter qef, Long courseResId, String shortTitle, String olatResourceDetail, RepositoryEntry testRe, ZipOutputStream exportStream, Locale locale, String fileNameSuffix) throws IOException {
    boolean resultsFoundAndExported = false;
    QTIResultManager qrm = QTIResultManager.getInstance();
    List<QTIResult> results = qrm.selectResults(courseResId, olatResourceDetail, testRe.getKey(), null, qef.getType());
    if (results.size() > 0) {
        List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(testRe);
        qef.setQTIItemObjectList(qtiItemObjectList);
        if (results.size() > 0) {
            createContentOfExportFile(results, qtiItemObjectList, qef);
            String targetFileName = getFilename(shortTitle, fileNameSuffix);
            exportStream.putNextEntry(new ZipEntry(targetFileName));
            IOUtils.write(qef.getReport(), exportStream);
            exportStream.closeEntry();
            resultsFoundAndExported = true;
        }
    } else {
        String targetFileName = getFilename(shortTitle, fileNameSuffix);
        exportStream.putNextEntry(new ZipEntry(targetFileName));
        Translator translator = Util.createPackageTranslator(QTIExportFormatter.class, locale);
        IOUtils.write(translator.translate("archive.noresults.short"), exportStream);
        exportStream.closeEntry();
        resultsFoundAndExported = true;
    }
    return resultsFoundAndExported;
}
Also used : QTIResult(org.olat.ims.qti.QTIResult) QTIResultManager(org.olat.ims.qti.QTIResultManager) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) Translator(org.olat.core.gui.translator.Translator) QTIObjectTreeBuilder(org.olat.ims.qti.export.helper.QTIObjectTreeBuilder) ZipEntry(java.util.zip.ZipEntry)

Example 50 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class ForumNotificationsHandler method createSubscriptionInfo.

/**
 * @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
 *      java.util.Locale, java.util.Date)
 */
@Override
public SubscriptionInfo createSubscriptionInfo(final Subscriber subscriber, Locale locale, Date compareDate) {
    try {
        Publisher p = subscriber.getPublisher();
        Date latestNews = p.getLatestNewsDate();
        SubscriptionInfo si;
        // there could be news for me, investigate deeper
        if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
            String businessControlString = "";
            Long forumKey = Long.valueOf(0);
            try {
                forumKey = Long.parseLong(p.getData());
            } catch (NumberFormatException e) {
                logError("Could not parse forum key!", e);
                NotificationsManager.getInstance().deactivate(p);
                return NotificationsManager.getInstance().getNoSubscriptionInfo();
            }
            if ("CourseModule".equals(p.getResName())) {
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(p.getResName(), p.getResId()), false);
                if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
                    return NotificationsManager.getInstance().getNoSubscriptionInfo();
                }
            }
            final List<Message> mInfos = ForumManager.getInstance().getNewMessageInfo(forumKey, compareDate);
            final Translator translator = Util.createPackageTranslator(ForumNotificationsHandler.class, locale);
            businessControlString = p.getBusinessPath() + "[Message:";
            si = new SubscriptionInfo(subscriber.getKey(), p.getType(), getTitleItem(p, translator), null);
            for (Message mInfo : mInfos) {
                String title = mInfo.getTitle();
                Identity creator = mInfo.getCreator();
                Identity modifier = mInfo.getModifier();
                Date modDate = mInfo.getLastModified();
                String name;
                if (modifier != null) {
                    if (modifier.equals(creator) && StringHelper.containsNonWhitespace(mInfo.getPseudonym())) {
                        name = mInfo.getPseudonym();
                    } else {
                        name = NotificationHelper.getFormatedName(modifier);
                    }
                } else if (StringHelper.containsNonWhitespace(mInfo.getPseudonym())) {
                    name = mInfo.getPseudonym();
                } else if (mInfo.isGuest()) {
                    name = translator.translate("anonymous.poster");
                } else {
                    name = NotificationHelper.getFormatedName(creator);
                }
                final String descKey = "notifications.entry" + (mInfo.getCreationDate().equals(mInfo.getLastModified()) ? "" : ".modified");
                final String desc = translator.translate(descKey, new String[] { title, name });
                String urlToSend = null;
                String businessPath = null;
                if (p.getBusinessPath() != null) {
                    businessPath = businessControlString + mInfo.getKey().toString() + "]";
                    urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                }
                SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, ForumHelper.CSS_ICON_CLASS_MESSAGE);
                si.addSubscriptionListItem(subListItem);
            }
        } else {
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
        return si;
    } catch (Exception e) {
        log.error("Error while creating forum's notifications from publisher with key:" + subscriber.getKey(), e);
        checkPublisher(subscriber.getPublisher());
        return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
}
Also used : SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator) Identity(org.olat.core.id.Identity)

Aggregations

Translator (org.olat.core.gui.translator.Translator)586 Identity (org.olat.core.id.Identity)62 Date (java.util.Date)54 Controller (org.olat.core.gui.control.Controller)54 RepositoryEntry (org.olat.repository.RepositoryEntry)54 Locale (java.util.Locale)52 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)46 ArrayList (java.util.ArrayList)40 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)40 NodeEditController (org.olat.course.editor.NodeEditController)40 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)36 Roles (org.olat.core.id.Roles)36 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)36 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)32 Publisher (org.olat.core.commons.services.notifications.Publisher)30 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 MailBundle (org.olat.core.util.mail.MailBundle)28 ICourse (org.olat.course.ICourse)26 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)26