Search in sources :

Example 16 with PackageTranslator

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

the class Util method createPackageTranslator.

public static Translator createPackageTranslator(Class<?> baseClass, Class<?> fallbackClass, Locale locale) {
    String fallbackpackage = Util.getPackageName(fallbackClass);
    Translator fallback = new PackageTranslator(fallbackpackage, locale);
    String transpackage = Util.getPackageName(baseClass);
    Translator translator = new PackageTranslator(transpackage, locale, fallback);
    return translator;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 17 with PackageTranslator

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

the class Util method createPackageTranslator.

public static Translator createPackageTranslator(Translator baseClass, Class<?> fallbackClass, Locale locale) {
    String fallbackpackage = Util.getPackageName(fallbackClass);
    Translator fallback = new PackageTranslator(fallbackpackage, locale);
    Translator translator = new PackageTranslator(((PackageTranslator) baseClass).getPackageName(), locale, fallback);
    return translator;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 18 with PackageTranslator

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

the class UserWebService method validateProperty.

private boolean validateProperty(User user, String value, UserPropertyHandler userPropertyHandler, List<ErrorVO> errors, UserManager um, Locale locale) {
    ValidationError error = new ValidationError();
    if (!StringHelper.containsNonWhitespace(value) && um.isMandatoryUserProperty(PROPERTY_HANDLER_IDENTIFIER, userPropertyHandler)) {
        Translator translator = new PackageTranslator("org.olat.core", locale);
        String translation = translator.translate("new.form.mandatory");
        errors.add(new ErrorVO("org.olat.core:new.form.mandatory:" + userPropertyHandler.getName(), translation));
        return false;
    }
    value = parseUserProperty(value, userPropertyHandler, locale);
    if (!userPropertyHandler.isValidValue(user, value, error, locale)) {
        String pack = userPropertyHandler.getClass().getPackage().getName();
        Translator translator = new PackageTranslator(pack, locale);
        String translation = translator.translate(error.getErrorKey(), error.getArgs());
        errors.add(new ErrorVO(pack, error.getErrorKey(), translation));
        return false;
    } else if ((userPropertyHandler.getName().equals(UserConstants.INSTITUTIONALEMAIL) && StringHelper.containsNonWhitespace(value)) || userPropertyHandler.getName().equals(UserConstants.EMAIL)) {
        if (!UserManager.getInstance().isEmailAllowed(value, user)) {
            String pack = userPropertyHandler.getClass().getPackage().getName();
            Translator translator = new PackageTranslator(pack, locale);
            String translation = translator.translate("form.name." + userPropertyHandler.getName() + ".error.exists", new String[] { value });
            translation += " (" + value + ")";
            errors.add(new ErrorVO("org.olat.user.propertyhandlers:new.form.name." + userPropertyHandler.getName() + ".exists", translation));
        }
    }
    return true;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) ErrorVO(org.olat.restapi.support.vo.ErrorVO) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) ValidationError(org.olat.core.gui.components.form.ValidationError)

Example 19 with PackageTranslator

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

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 20 with PackageTranslator

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

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)

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