Search in sources :

Example 31 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class ENCourseNode 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)
 */
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    Controller controller;
    migrateConfig();
    // Do not allow guests to enroll to groups
    Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
        Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
        String title = trans.translate("guestnoaccess.title");
        String message = trans.translate("guestnoaccess.message");
        controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
        controller = new ENRunController(getModuleConfiguration(), ureq, wControl, userCourseEnv, this);
    }
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_en_icon");
    return new NodeRunConstructionResult(ctrl);
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) Roles(org.olat.core.id.Roles) ENRunController(org.olat.course.nodes.en.ENRunController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ENEditController(org.olat.course.nodes.en.ENEditController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ENRunController(org.olat.course.nodes.en.ENRunController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 32 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class StatusDescription method getLongDescription.

/**
 * localized long description of the status containing details, references
 * etc.
 *
 * @param locale
 * @return
 */
public String getLongDescription(Locale locale) {
    Translator f = Util.createPackageTranslator(ConditionEditController.class, locale);
    Translator t = new PackageTranslator(transPckg, locale, f);
    return t.translate(longDesc, params);
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 33 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class StatusDescription method getShortDescription.

/**
 * localized short description of the status providing a summary (line).
 *
 * @param locale
 * @return
 */
public String getShortDescription(Locale locale) {
    Translator f = Util.createPackageTranslator(ConditionEditController.class, locale);
    Translator t = new PackageTranslator(transPckg, locale, f);
    return t.translate(shortDesc, params);
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 34 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class FormLayoutContainer method add.

@Override
public void add(String name, FormItem formComp) {
    if (!hasRootForm) {
        throw new AssertionError("first ensure that the layout container knows about its rootform!!");
    }
    // set the formtranslator, and parent
    Translator itemTranslator = formComp.getTranslator();
    if (itemTranslator != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    formComp.setTranslator(itemTranslator);
    formComp.setRootForm(getRootForm());
    // 
    String formCompName = name;
    // book keeping of FormComponent order
    formComponentsNames.add(formCompName);
    formComponents.put(formCompName, formComp);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, formComp.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, formComp.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, formComp.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, formComp.getLabelC());
    // Check for multipart data, add upload limit to form
    if (formComp instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Example 35 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class VelocityRenderDecorator method translateWithPackage.

/**
 * Method to translate a key that comes from another package. This should be
 * used rarely. When a key is used withing multiple packages is is usually
 * better to use a fallback translator or to move the key to the default
 * packages.
 * <p>
 * Used in context help system
 * @param bundleName the package name, e.g. 'org.olat.core'
 * @param key the key, e.g. 'my.key'
 * @param args optional arguments, null if not used
 * @return
 */
public String translateWithPackage(String bundleName, String key, String[] args) {
    Translator pageTrans = renderer.getTranslator();
    if (pageTrans == null)
        return "{Translator is null: key_to_translate=" + key + "}";
    Locale locale = pageTrans.getLocale();
    Translator tempTrans = new PackageTranslator(bundleName, locale);
    String result = tempTrans.translate(key, args);
    if (result == null) {
        return "{Invalid bundle name: " + bundleName + " and key: " + key + "}";
    }
    return result;
}
Also used : Locale(java.util.Locale) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator)

Aggregations

PackageTranslator (org.olat.core.gui.translator.PackageTranslator)40 Translator (org.olat.core.gui.translator.Translator)34 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)8 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)8 Property (org.olat.properties.Property)8 Controller (org.olat.core.gui.control.Controller)6 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)6 Roles (org.olat.core.id.Roles)6 NodeEditController (org.olat.course.editor.NodeEditController)6 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)6 File (java.io.File)4 FormMultipartItem (org.olat.core.gui.components.form.flexible.FormMultipartItem)4 AssessmentCourseNodeController (org.olat.course.assessment.ui.tool.AssessmentCourseNodeController)4 MSEditFormController (org.olat.course.nodes.ms.MSEditFormController)4 DropboxController (org.olat.course.nodes.ta.DropboxController)4 ReturnboxController (org.olat.course.nodes.ta.ReturnboxController)4 TaskController (org.olat.course.nodes.ta.TaskController)4 Locale (java.util.Locale)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 BusinessControl (org.olat.core.id.context.BusinessControl)2