Package org.olat.core.gui.translator

Examples of org.olat.core.gui.translator.PackageTranslator


    //TODO remove the below warn again once OLAT-5715 has been resolved - or it turns out that below warn is too verbose
    // the idea is that at this stage the throwable still contains a stacktrace but passed into the OLATRuntimeException
    // below as the cause it somehow gets lost. If this does not turn out to be true then the line below can be removed.
    // in any case, it is just a log.warn
    Tracing.logWarn("ExceptionWindowController<init>: Throwable occurred, logging the full stacktrace:", th, getClass());
    Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
    Formatter formatter = Formatter.getInstance(ureq.getLocale());
    msg = new VelocityContainer("olatmain", VELOCITY_ROOT + "/exception_page.html", trans, this);
    // disallow wrapping of divs around the panel and the main velocity page
    // (since it contains the "<html><head... intro of the html page,
    // and thus has better to be replaced as a whole (new page load) instead of
    // a dom replacement)
    msg.setDomReplaceable(false);
   
    Version v = (Version) CoreSpringFactory.getBean("org.olat.core.Version");
    msg.contextPut("buildversion", v.getVersion());

    OLATRuntimeException o3e;
   
    if (th == null){
      o3e = new OLATRuntimeException("Error Screen with a Throwable == null", null);
    } else if (!(th instanceof OLATRuntimeException)) {
      o3e = new OLATRuntimeException(th.getMessage(), th);
    } else {
      o3e = (OLATRuntimeException) th;
    }

    String detailedmessage = null;
    // translate user message if available
    if (o3e.getUsrMsgKey() != null && o3e.getUsrMsgPackage() != null) {
      PackageTranslator usrMsgTrans = new PackageTranslator(o3e.getUsrMsgPackage(), ureq.getLocale());
      if (o3e.getUsrMsgArgs() == null) {
        detailedmessage = usrMsgTrans.translate(o3e.getUsrMsgKey());
      } else {
        detailedmessage = usrMsgTrans.translate(o3e.getUsrMsgKey(), o3e.getUsrMsgArgs());
      }
    }
    // fix detailed message
    if (detailedmessage == null) {
      if (o3e instanceof StaleObjectRuntimeException) {
View Full Code Here


    this.bundleName = bundleName;
    this.page = page;
    contextHelpWrapperVC = createVelocityContainer("contexthelpwrapper");   
    // Initialize the page mapper - must be done before calling createHelpPage()
    initPageResourceMapper()
    pageTranslator = new PackageTranslator(bundleName, getLocale());
    contextHelpPageVC = createHelpPage(bundleName, page);               
   
    // Add page infos and rating
    addPageInfos();
    addPageRating(ureq);
View Full Code Here

    *
    *
    */
  public SinglePageController(UserRequest ureq, WindowControl wControl, boolean inIframe, VFSContainer rootContainer, String fileName, String currentUri, boolean allowRelativeLinks, boolean showHomeLink, OLATResourceable contextResourcable) {
    super(wControl);
    trans = new PackageTranslator(PACKAGE, ureq.getLocale());
    Panel mainP = new Panel("iframemain");
    myContent = new VelocityContainer("singlepagecontent", VELOCITY_ROOT + "/index.html", trans, this);
   
    homeLinkP = new Panel("homelink");
    homeLinkContent = new VelocityContainer("homelinkcontent", VELOCITY_ROOT + "/homelink.html", trans, this);
View Full Code Here

   * @param locale locale that should be used for message localization
   */
  public Emailer(Locale locale) {
    this.mailfrom =  WebappHelper.getMailConfig("mailFrom");
    // initialize the mail footer with info about this OLAt installation
    PackageTranslator trans = new PackageTranslator(Util.getPackageName(Emailer.class), locale);
    footer = trans.translate("footer.no.userdata", new String[] { Settings.getServerContextPathURI() });
  }
View Full Code Here

    // initialize the mail footer with infos about this OLAT installation and the user who sent the mail
    User user = mailFromIdentity.getUser();
   
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(user.getPreferences().getLanguage());
   
    PackageTranslator trans = new PackageTranslator(Util.getPackageName(Emailer.class), locale);
    String institution = user.getProperty(UserConstants.INSTITUTIONALNAME, null);
    if (institution == null) institution = "";
    footer = trans.translate("footer.with.userdata", new String[] { user.getProperty(UserConstants.FIRSTNAME, null), user.getProperty(UserConstants.LASTNAME, null), mailFromIdentity.getName(),
        institution, Settings.getServerContextPathURI()  });

  }
View Full Code Here

   * @param template Default values taken from this template
   * @param useCancel
   * @param listeningController Controller that listens to form events
   */
  public MailTemplateForm(Locale locale, MailTemplate template, boolean useCancel, Controller listeningController) {
    super("MailTemplateForm", new PackageTranslator(Util.getPackageName(MailTemplateForm.class), locale));
   
    addListener(listeningController);

    String[] skipKeys = new String[] { Boolean.TRUE.toString(), Boolean.FALSE.toString() };
    String[] skipValues = new String[] { translate("yes"), translate("no") };
View Full Code Here

   * @param maxSteps
   */
  public WizardInfoController(UserRequest ureq, int maxSteps) {
    super(null);
    this.maxSteps = maxSteps;
    Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
    myContent = new VelocityContainer("genericwizard", VELOCITY_ROOT + "/wizard_steps.html", trans, null);

    myContent.contextPut("max", String.valueOf(maxSteps));
    myContent.contextPut("myself", this);
    setCurStep(1);
View Full Code Here

   * @param steps
   */
  public WizardController(UserRequest ureq, WindowControl wControl, int steps) { super(wControl);
    this.steps = steps;
   
    this.trans = new PackageTranslator(PACKAGE, ureq.getLocale());
    this.wizardVC = new VelocityContainer("wizard", VELOCITY_ROOT + "/wizard.html", this.trans, this);
    finishButton = LinkFactory.createCustomLink("finish", "cmd.wizard.cancel", "cmd.wizard.finished", Link.BUTTON, this.wizardVC, this);
    cancelButton = LinkFactory.createCustomLink("cancel", "cmd.wizard.cancel", "cmd.wizard.cancel", Link.BUTTON, this.wizardVC, this);
   
    this.wic = new WizardInfoController(ureq, this.steps);
View Full Code Here

  private static Translator getTranslator(Locale locale) {
    String ident = locale.toString();
    synchronized (translators) {  //o_clusterok   brasato:::: nice idea, but move to translatorfactory and kick out translator.setLocale() (move it to LocaleChangableTranslator)
      Translator trans = translators.get(ident);
      if (trans == null) {
        trans = new PackageTranslator(Util.getPackageName(Emailer.class), locale);
        translators.put(ident, trans);
      }
      return trans;
    }
  }
View Full Code Here

   * @param errors StringBuilder for the error messages
   * @param warnings StringBuilder for the warnings
   * @param locale The users local
   */
  public static void appendErrorsAndWarnings(MailerResult mailerResult, StringBuilder errors, StringBuilder warnings, Locale locale) {
    Translator trans = new PackageTranslator(Util.getPackageName(MailerResult.class), locale);
    int returnCode = mailerResult.getReturnCode();
    List<Identity> failedIdentites = mailerResult.getFailedIdentites();

    // first the severe errors
    if (returnCode == MailerResult.SEND_GENERAL_ERROR) {
      errors.append("<p>").append(trans.translate("mailhelper.error.send.general")).append("</p>");
    } else if (returnCode == MailerResult.SENDER_ADDRESS_ERROR) {
      errors.append("<p>").append(trans.translate("mailhelper.error.sender.address")).append("</p>");
    } else if (returnCode == MailerResult.RECIPIENT_ADDRESS_ERROR) {
      errors.append("<p>").append(trans.translate("mailhelper.error.recipient.address")).append("</p>");
    } else if (returnCode == MailerResult.TEMPLATE_GENERAL_ERROR) {
      errors.append("<p>").append(trans.translate("mailhelper.error.template.general")).append("</p>");
    } else if (returnCode == MailerResult.TEMPLATE_PARSE_ERROR) {
      errors.append("<p>").append(trans.translate("mailhelper.error.template.parse")).append("</p>");
    } else if (returnCode == MailerResult.ATTACHMENT_INVALID) {
      errors.append("<p>").append(trans.translate("mailhelper.error.attachment")).append("</p>");
    } else {
      // mail could be send, but maybe not to all the users (e.g. invalid mail
      // adresses or a temporary problem)
      if (failedIdentites != null && failedIdentites.size() > 0) {
        warnings.append("<p>").append(trans.translate("mailhelper.error.failedusers"));
        warnings.append("<ul>");
        for (Identity identity : failedIdentites) {
          User user = identity.getUser();
          warnings.append("<li>");
          warnings.append(trans.translate("mailhelper.error.failedusers.user", new String[] { user.getProperty(UserConstants.FIRSTNAME, null), user.getProperty(UserConstants.LASTNAME, null),
              user.getProperty(UserConstants.EMAIL, null), identity.getName() }));
          warnings.append("</li>");
        }
        warnings.append("</ul></p>");
      }
View Full Code Here

TOP

Related Classes of org.olat.core.gui.translator.PackageTranslator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.