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