Package org.olat.core.util.i18n

Examples of org.olat.core.util.i18n.I18nManager$ThreadLocalMarkLocalizedStrings


   *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
   */
  @Override
  protected void initForm(FormItemContainer formLayout, @SuppressWarnings("unused") Controller listener,
      @SuppressWarnings("unused") UserRequest ureq) {
    I18nManager i18nMgr = I18nManager.getInstance();
    // A title, displayed in fieldset
    setFormTitle("configuration.management.package.export.title");
    setFormDescription("configuration.management.package.export.description");
    //
    // Add languages checkboxes
    Set<String> availableKeysUnsorted = I18nModule.getAvailableLanguageKeys();
    String[] availableKeys = ArrayHelper.toArray(availableKeysUnsorted);
    String[] availableValues = new String[availableKeys.length];
    for (int i = 0; i < availableKeys.length; i++) {
      String key = availableKeys[i];
      String explLang = i18nMgr.getLanguageInEnglish(key, false);
      String all = explLang;
      if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
      availableValues[i] = all;
    }
    ArrayHelper.sort(availableKeys, availableValues, false, true, false);
    String[] availableLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(availableKeys, "b_with_small_icon_left");
    exportLangSelection = uifactory.addCheckboxesVertical("configuration.exportLangSelection", null, formLayout, availableKeys,
        availableValues, availableLangCssClasses, 2);
    exportLangSelection.addActionListener(this, FormEvent.ONCLICK);
    // Add cancel and submit in button group layout
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
View Full Code Here


   *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
   */
  @Override
  protected void initForm(FormItemContainer formLayout, @SuppressWarnings("unused") Controller listener,
      @SuppressWarnings("unused") UserRequest ureq) {
    I18nManager i18nMgr = I18nManager.getInstance();
    // A title, displayed in fieldset
    setFormTitle("configuration.management.delete.title");
    setFormDescription("configuration.management.delete.description");
    //
    // Add languages checkboxes
    Set<String> deletableKeysUnsorted = I18nModule.getTranslatableLanguageKeys();
    String[] deletableKeys = ArrayHelper.toArray(deletableKeysUnsorted);
    String[] availableValues = new String[deletableKeys.length];
    for (int i = 0; i < deletableKeys.length; i++) {
      String key = deletableKeys[i];
      String explLang = i18nMgr.getLanguageInEnglish(key, false);
      String all = explLang;
      if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
      availableValues[i] = all;
    }
    ArrayHelper.sort(deletableKeys, availableValues, false, true, false);
    String[] availableLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(deletableKeys, "b_with_small_icon_left");
    deleteLangSelection = uifactory.addCheckboxesVertical("configuration.deleteLangSelection", null, formLayout, deletableKeys,
        availableValues, availableLangCssClasses, 2);
    deleteLangSelection.addActionListener(this, FormEvent.ONCLICK);
    // Add cancel and submit in button group layout
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
View Full Code Here

   * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
   *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
   */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    I18nManager i18nMgr = I18nManager.getInstance();
    //
    // Add default languages pulldown
    Set<String> availableKeys = I18nModule.getAvailableLanguageKeys();
    String[] defaultlangKeys = ArrayHelper.toArray(availableKeys);
    String[] defaultLangValues = new String[defaultlangKeys.length];
    for (int i = 0; i < defaultlangKeys.length; i++) {
      String key = defaultlangKeys[i];
      String explLang = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
      String all = explLang;
      if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
      defaultLangValues[i] = all;
    }
    ArrayHelper.sort(defaultlangKeys, defaultLangValues, false, true, false);
    String[] defaultLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(defaultlangKeys, "b_with_small_icon_left");
    defaultLangSelection = uifactory.addDropdownSingleselect("configuration.defaultLangSelection", formLayout, defaultlangKeys,
        defaultLangValues, defaultLangCssClasses);
    defaultLangSelection.addActionListener(this, FormEvent.ONCHANGE);
    // Enable the current default language
    Locale defaultLocale = I18nModule.getDefaultLocale();
    this.flc.contextPut("defaultLangKey", defaultLocale.toString());
    defaultLangSelection.select(defaultLocale.toString(), true);
    //
    // Add enabled languages checkboxes
    String[] availablelangKeys = ArrayHelper.toArray(availableKeys);
    String[] availableValues = new String[availablelangKeys.length];
    int referenceKeyCount = i18nMgr.countI18nItems(I18nModule.getFallbackLocale(), null, true);
    for (int i = 0; i < availablelangKeys.length; i++) {
      String key = availablelangKeys[i];
      String explLang = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
      String all = explLang;
      if (explLang != null && !explLang.equals(key)) all += " (" + key + ")";
      // count translation status
      int keyCount = i18nMgr.countI18nItems(i18nMgr.getLocaleOrNull(key), null, true);
      all += "   <span class='b_translation_status'>" + (keyCount * 100 / referenceKeyCount) + "%</span>";
      availableValues[i] = all;
    }
    ArrayHelper.sort(availablelangKeys, availableValues, false, true, false);
    String[] availableLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(availablelangKeys, "b_with_small_icon_left");
    enabledLangSelection = uifactory.addCheckboxesVertical("configuration.enabledLangSelection", null, formLayout, availablelangKeys,
        availableValues, availableLangCssClasses, 2);
    enabledLangSelection.addActionListener(this, FormEvent.ONCHANGE);
    // Enable current enabled languages
    for (String langKey : I18nModule.getEnabledLanguageKeys()) {
View Full Code Here

        // Get userconfigured reference locale
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        List<String> referenceLangs = I18nModule.getTransToolReferenceLanguages();
        String referencePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_REFERENCE_LANG, referenceLangs
            .get(0));
        I18nManager i18nMgr = I18nManager.getInstance();
        Locale referenceLocale = i18nMgr.getLocaleOrNull(referencePrefs);
        // Set target local to current user language
        Locale targetLocale = i18nMgr.getLocaleOrNull(ureq.getLocale().toString());
        if (I18nModule.isOverlayEnabled() && !I18nModule.isTransToolEnabled()) {
          // use overlay locale when in customizing mode
          targetLocale = I18nModule.getOverlayLocales().get(targetLocale)
        }
        List<I18nItem> i18nItems = i18nMgr.findExistingAndMissingI18nItems(referenceLocale, targetLocale, bundle, false);
        i18nMgr.sortI18nItems(i18nItems, true, true); // sort with priority
        // Initialize inline translation controller
        if (i18nItemEditCtr != null) removeAsListenerAndDispose(i18nItemEditCtr);
        // Disable inline translation markup while inline translation tool is
        // running -
        // must be done before instantiating the translation controller
        i18nMgr.setMarkLocalizedStringsEnabled(ureq.getUserSession(), false);
        i18nItemEditCtr = new TranslationToolI18nItemEditCrumbController(ureq, getWindowControl(), i18nItems, referenceLocale, !I18nModule.isTransToolEnabled());
        listenTo(i18nItemEditCtr);
        // set current key from the package as current translation item
        for (I18nItem item : i18nItems) {
          if (item.getKey().equals(key)) {
View Full Code Here

    searchController.setResourceContextEnable(false);
    searchController.setDocumentType("type.contexthelp");
    flc.add("search_input", searchController.getFormItem());
   
    // Add target languages without overlays
    I18nManager i18nMgr = I18nManager.getInstance();
    Set<String> availableLangKeys = I18nModule.getEnabledLanguageKeys();
    String[] targetlangKeys = ArrayHelper.toArray(availableLangKeys);
    String[] targetLangValues = new String[targetlangKeys.length];
    for (int i = 0; i < targetlangKeys.length; i++) {
      String key = targetlangKeys[i];
      String name = i18nMgr.getLanguageTranslated(key, I18nModule.isOverlayEnabled());
      targetLangValues[i] = name;
    }
    ArrayHelper.sort(targetlangKeys, targetLangValues, false, true, false);
    // Build css classes for reference languages
    String[] targetLangCssClasses = i18nMgr.createLanguageFlagsCssClasses(targetlangKeys, "b_with_small_icon_left");
    langSelection = uifactory.addDropdownSingleselect("contexthelp.langSelection", formLayout, targetlangKeys, targetLangValues, targetLangCssClasses);
    langSelection.addActionListener(this, FormEvent.ONCHANGE);           
    // Preselect language from URL
    langSelection.select(getLocale().toString(), true);
    this.flc.contextPut("lang", getLocale().toString());
View Full Code Here

   * Should not be called directly, use translate(String key, String[] args).
   * Must be public, because the definition is in an interface.
   * @see org.olat.core.gui.translator.Translator#translate(java.lang.String, java.lang.String[], boolean)
   */
  public String translate(String key, String[] args, boolean fallBackToDefaultLocale) {
    I18nManager i18n = I18nManager.getInstance();
    boolean overlayEnabled = I18nModule.isOverlayEnabled();
    String val = i18n.getLocalizedString(packageName, key, args, locale, overlayEnabled, fallBackToDefaultLocale);
    if (val == null) {
      // if not found, try the fallBackTranslator
      if (fallBackTranslator != null) {
        val = fallBackTranslator.translate(key, args, fallBackToDefaultLocale);
      } else if (fallBack) { // both fallback and fallbacktranslator does not
        // make sense; latest translator in chain should
        // fallback to application fallback.
        val = i18n.getLocalizedString(I18nModule.getApplicationFallbackBundle(), key, args, locale, overlayEnabled, fallBackToDefaultLocale);
        if (val == null) {
          // lastly fall back to brasato framework fallback
          val = i18n.getLocalizedString(I18nModule.getBrasatoFallbackBundle(), key, args, locale, overlayEnabled, fallBackToDefaultLocale);
        }
      }
    }
    return val;
  }
View Full Code Here

   *
   * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
   */
  public int compare(WikiPage a, WikiPage b) {
    // Be aware of locale when ordering
    I18nManager mgr = I18nManager.getInstance();
    Locale userLocale = mgr.getCurrentThreadLocale();
    Collator collator = Collator.getInstance(userLocale);
    collator.setStrength(Collator.PRIMARY);

    // Undefinied order if page a or b is null
    int order = 0;
View Full Code Here

   * @param pagePath
   * @return
   */
  public static Document createDocument(SearchResourceContext searchResourceContext, String bundleName, String page, Translator pageTranslator, Context ctx, String pagePath) {
    ContextHelpDocument contextHelpDocument = new ContextHelpDocument()
    I18nManager i18nMgr = I18nManager.getInstance();
   
    // Set all know attributes
    searchResourceContext.setFilePath(ContextHelpDispatcher.createContextHelpURI(pageTranslator.getLocale(), bundleName, page));
    contextHelpDocument.setResourceUrl(searchResourceContext.getResourceUrl());//to adhere to the [path=...] convention
    contextHelpDocument.setLastChange(new Date(i18nMgr.getLastModifiedDate(pageTranslator.getLocale(), bundleName)));
    String lang = I18nManager.getInstance().getLanguageTranslated(pageTranslator.getLocale().toString(), I18nModule.isOverlayEnabled());
    contextHelpDocument.setDocumentType(TYPE)
    contextHelpDocument.setCssIcon("b_contexthelp_icon");
    contextHelpDocument.setTitle(pageTranslator.translate("chelp." + page.split("\\.")[0] + ".title") + " (" + lang + ")");
   
View Full Code Here

        CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
        insertedNode = newNodeConfig.getInstance();

        // Set some default values
        ///// START Special inline translation case: disable inline translation rendering (generates too long titles)
        I18nManager i18nMgr = I18nManager.getInstance();
        boolean isInlineTrans = i18nMgr.isCurrentThreadMarkLocalizedStringsEnabled();
        if (isInlineTrans) {
          i18nMgr.setMarkLocalizedStringsEnabled(ureq.getUserSession(), false);
        }
        //--
        String title = new String(newNodeConfig.getLinkText(ureq.getLocale()));
        insertedNode.setShortTitle(title);
        String longTitle = new String(translate("longtitle.default") + " " + title);
        insertedNode.setLongTitle(longTitle);
        insertedNode.setNoAccessExplanation(translate("form.noAccessExplanation.default"));
        //--
        if (isInlineTrans) {
          i18nMgr.setMarkLocalizedStringsEnabled(ureq.getUserSession(), true);
        }
        ///// END Special inline translation case
       
        // Insert it now
        CourseNode selectedNode = insertModel.getCourseNode(tp.getParentTreeNode());
View Full Code Here

          // Add version info and licenses
          Version v = (Version)CoreSpringFactory.getBean("org.olat.core.Version");
          aboutVC.contextPut("version", v.getFullVersion());
          aboutVC.contextPut("license", WebappHelper.getOlatLicense());
          // Add translator and languages info
          I18nManager i18nMgr = I18nManager.getInstance();
          Set<String> enabledKeysSet = I18nModule.getEnabledLanguageKeys();
          Map<String, String> langNames = new HashMap<String, String>();
          Map<String, String> langTranslators = new HashMap<String, String>();
          String[] enabledKeys = ArrayHelper.toArray(enabledKeysSet);
          String[] names = new String[enabledKeys.length];
          for (int i = 0; i < enabledKeys.length; i++) {
            String key = enabledKeys[i];
            String langName = i18nMgr.getLanguageInEnglish(key, I18nModule.isOverlayEnabled());
            langNames.put(key, langName);
            names[i] = langName;
            String author = i18nMgr.getLanguageAuthor(key);
            langTranslators.put(key, author);
          }
          ArrayHelper.sort(enabledKeys, names, true, true, true);
          aboutVC.contextPut("enabledKeys", enabledKeys);
          aboutVC.contextPut("langNames", langNames);
View Full Code Here

TOP

Related Classes of org.olat.core.util.i18n.I18nManager$ThreadLocalMarkLocalizedStrings

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.