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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations