Package org.olat.core.gui.translator

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


      if (locale == null) {
        //fallback to default locale
        locale = I18nModule.getDefaultLocale();
      }
      // place disposed message
      Translator pT = Util.createPackageTranslator(DefaultController.class, locale);
      Component dispMsgVC = new VelocityContainer(DEFAULTDISPOSED_PAGE,DefaultController.class,DEFAULTDISPOSED_PAGE,pT,null);
      wrapperPanel.pushContent(dispMsgVC);
    }
     
     
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 ident
   * @return
   */
  public static String getFormatedName(Identity ident) {
    Translator trans;
    User user = null;
    if (ident == null) {
      trans = Util.createPackageTranslator(NotificationHelper.class, I18nManager.getInstance().getLocaleOrDefault(null));
    } else {
     trans = Util.createPackageTranslator(NotificationHelper.class, I18nManager.getInstance().getLocaleOrDefault(
        ident.getUser().getPreferences().getLanguage()));
     user = ident.getUser();
    }
    if (user == null) return trans.translate("user.unknown");
    return user.getProperty(UserConstants.FIRSTNAME, null) + " " + user.getProperty(UserConstants.LASTNAME, null);
  }
View Full Code Here

   */
  public static String getMailFooter(Locale locale, Identity sender) {
    if (locale == null) {
      locale = I18nModule.getDefaultLocale();
    }
    Translator trans = getTranslator(locale);
    if (sender == null) {
      // mail sent by plattform configured sender address
      return trans.translate("footer.no.userdata", new String[] { Settings.getServerContextPathURI() });
    }
    // mail sent by a system user
    User user = sender.getUser();
    String institution = user.getProperty(UserConstants.INSTITUTIONALNAME, null);
    if (institution == null) institution = "";
    return trans.translate("footer.with.userdata", new String[] { user.getProperty(UserConstants.FIRSTNAME, null), user.getProperty(UserConstants.LASTNAME, null), sender.getName(),
        institution, Settings.getServerContextPathURI() });

  }
View Full Code Here

   * @return a translator for the given locale
   */
  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

    // (cnt > 0) render tabs
    int selPane = tb.getSelectedPane();
    boolean iframePostEnabled = renderer.getGlobalSettings().getAjaxFlags().isIframePostEnabled();
   
    // add overview info for screenreader
    Translator comptrans = tb.getCompTrans();
    sb.append(comptrans.translate("sr.intro", new String[] {String.valueOf(cnt)}));
    for (int i = 0; i < cnt; i++) {
      String tabName = tb.getDisplayNameAt(i);
      if (!tb.isEnabled(i)) {
        // if a pane is not enabled
        sb.append(comptrans.translate("sr.tab.notenabled", new String[] {tabName}));
      } else if (i == selPane) {
        // mark active pane
        sb.append(comptrans.translate("sr.tab.active", new String[] {tabName}));
      } else {
        // normal, enabled, but not active pane
        sb.append("<a href=\"");
        ubu.buildURI(sb, new String[]{ TabbedPane.PARAM_PANE_ID }, new String[]{ String.valueOf(i) }, iframePostEnabled? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
        sb.append("\" onclick=\"return o2cl()\"");
        if (iframePostEnabled) {
          ubu.appendTarget(sb);
        }
        sb.append(">");
        sb.append(comptrans.translate("sr.tab.normal", new String[] {tabName}));       
        sb.append("</a>");
      }
    }
    sb.append(comptrans.translate("sr.introcontent"));
    // now let the selected component render itself
    Component paneToRender = tb.getTabAt(selPane);
    if (paneToRender == null) throw new RuntimeException("a tabbed pane must not be null, but a component");
    renderer.render(sb, paneToRender, null);
  }
View Full Code Here

          }
        } else if (CMD_DELETE.equals(tEvent.getAction())) {
          List<Versions> versionsToDelete = getSelectedVersions(tEvent.getSelection());
          if (!versionsToDelete.isEmpty()) {
           
            Translator trans = getTranslator();
            String msg = trans.translate("version.del.confirm") + "<p>" + renderVersionsAsHtml(versionsToDelete) + "</p>";
            // create dialog controller
            dialogCtr = activateYesNoDialog(ureq, trans.translate("version.del.header"), msg, dialogCtr);
            dialogCtr.setUserObject(versionsToDelete);
          }
        }
      }
    } else if (source == dialogCtr) {
View Full Code Here

   * @param fallback The fallback translator that should be used
   * @return
   */
  public static Translator createPackageTranslator(Class baseClass, Locale locale, Translator fallback) {
    String transpackage = Util.getPackageName(baseClass);
    Translator trans;
    if(fallback != null) {
      trans = new PackageTranslator(transpackage, locale, fallback);
    } else {
      trans = new PackageTranslator(transpackage, locale);
    }
View Full Code Here

  @Override
  public void setTranslator(Translator translator) {
    // wrap package translator with fallback form translator
    // hint: do not take this.getClass() but the real class! for package translator creation
    Translator elmTranslator = Util.createPackageTranslator(TextAreaElementImpl.class, translator.getLocale(), translator);
    super.setTranslator(elmTranslator);
  }
View Full Code Here

TOP

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

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.