Search in sources :

Example 11 with I18nItem

use of org.olat.core.util.i18n.I18nItem in project openolat by klemens.

the class SingleKeyTranslatorController method deleteI18nKey.

/**
 * delete a key that is no longer used.
 *
 * @param key
 */
public void deleteI18nKey(String key) {
    for (I18nRowBundle bundle : bundles) {
        I18nItem item = i18nMng.getI18nItem(translatorBaseClass.getPackage().getName(), key, bundle.getOverlayLocale());
        i18nMng.saveOrUpdateI18nItem(item, "");
    }
}
Also used : I18nItem(org.olat.core.util.i18n.I18nItem)

Example 12 with I18nItem

use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.

the class TranslationDevManager method getDouplicateKeys.

// do this only for reference language!
public List<I18nItem> getDouplicateKeys() {
    Locale refLocale = i18nModule.getDefaultLocale();
    List<I18nItem> doupList = new ArrayList<I18nItem>();
    List<String> allBundles = i18nModule.getBundleNamesContainingI18nFiles();
    Map<String, String> tempKeyMap = new HashMap<String, String>();
    for (String bundleName : allBundles) {
        Properties properties = i18nMgr.getPropertiesWithoutResolvingRecursively(refLocale, bundleName);
        for (Iterator<Entry<Object, Object>> keyIter = properties.entrySet().iterator(); keyIter.hasNext(); ) {
            Entry<Object, Object> keyEntry = keyIter.next();
            String keyName = (String) keyEntry.getKey();
            String keyValue = (String) keyEntry.getValue();
            if (tempKeyMap.containsKey(keyName)) {
                List<I18nItem> tmpItem = i18nMgr.findI18nItemsByKeySearch(keyName, refLocale, refLocale, bundleName, false);
                doupList.addAll(tmpItem);
            } else {
                tempKeyMap.put(keyName, keyValue);
            }
        }
    }
    log.info("found " + doupList.size() + " douplicated keys");
    return doupList;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) Entry(java.util.Map.Entry) I18nItem(org.olat.core.util.i18n.I18nItem)

Example 13 with I18nItem

use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.

the class TranslationDevManager method addKey.

protected void addKey(Locale locale, String bundleName, String key, String value) {
    I18nItem i18nItem = new I18nItem(bundleName, key, locale, I18nManager.DEFAULT_BUNDLE_PRIORITY, I18nManager.DEFAULT_KEY_PRIORITY);
    i18nMgr.saveOrUpdateI18nItem(i18nItem, value);
}
Also used : I18nItem(org.olat.core.util.i18n.I18nItem)

Example 14 with I18nItem

use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.

the class TranslationDevManager method getDouplicateValues.

// do this only for reference language!
public List<I18nItem> getDouplicateValues() {
    Locale refLocale = i18nModule.getDefaultLocale();
    List<I18nItem> doupList = new ArrayList<I18nItem>();
    List<String> allBundles = i18nModule.getBundleNamesContainingI18nFiles();
    Map<String, String> tempKeyMap = new HashMap<String, String>();
    for (String bundleName : allBundles) {
        Properties properties = i18nMgr.getPropertiesWithoutResolvingRecursively(refLocale, bundleName);
        for (Iterator<Entry<Object, Object>> keyIter = properties.entrySet().iterator(); keyIter.hasNext(); ) {
            Entry<Object, Object> keyEntry = keyIter.next();
            String keyName = (String) keyEntry.getKey();
            String keyValue = (String) keyEntry.getValue();
            if (tempKeyMap.containsKey(keyName)) {
                List<I18nItem> tmpItem = i18nMgr.findI18nItemsByValueSearch(keyValue, refLocale, refLocale, bundleName, false);
                doupList.addAll(tmpItem);
            } else {
                tempKeyMap.put(keyValue, keyName);
            }
        }
    }
    log.info("found " + doupList.size() + " douplicated values in keys");
    return doupList;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) Entry(java.util.Map.Entry) I18nItem(org.olat.core.util.i18n.I18nItem)

Example 15 with I18nItem

use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.

the class TranslationToolI18nItemListCrumbController method initForm.

/*
	 * (non-Javadoc)
	 * 
	 * @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) {
    // Add the translate all button
    allTranslateButtonTop = new FormLinkImpl("allTranslateButtonTop", "allTranslateButtonTop", "generic.translateAllButton", Link.BUTTON);
    formLayout.add(allTranslateButtonTop);
    allTranslateButtonBottom = new FormLinkImpl("allTranslateButtonBottom", "allTranslateButtonBottom", "generic.translateAllButton", Link.BUTTON);
    formLayout.add(allTranslateButtonBottom);
    // Add a translate button for each package
    String currentBundleName = null;
    int bundlesCount = 0;
    for (I18nItem item : i18nItems) {
        if (!item.getBundleName().equals(currentBundleName)) {
            currentBundleName = item.getBundleName();
            String linkName = "translateBundle_" + currentBundleName;
            String label = (customizingMode ? "generic.customize.translateButton" : "generic.translateButton");
            FormLink bundleTranslateButton = new FormLinkImpl(linkName, linkName, label, Link.BUTTON_SMALL);
            // use first item of bundle
            bundleTranslateButton.setUserObject(item);
            formLayout.add(bundleTranslateButton);
            bundlesCount++;
        }
    }
    // Add all the items to velocity
    this.flc.contextPut("i18nItems", i18nItems);
    this.flc.contextPut("bundlesCount", bundlesCount);
    this.flc.contextPut("keysCount", i18nItems.size());
    // Override text labels for customizing mode
    if (customizingMode) {
        allTranslateButtonTop.setI18nKey("generic.customize.translateAllButton");
        allTranslateButtonBottom.setI18nKey("generic.customize.translateAllButton");
    }
    this.flc.contextPut("customizingMode", Boolean.valueOf(customizingMode));
    this.flc.contextPut("customizingPrefix", (customizingMode ? "customize." : ""));
}
Also used : I18nItem(org.olat.core.util.i18n.I18nItem) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

I18nItem (org.olat.core.util.i18n.I18nItem)24 ArrayList (java.util.ArrayList)8 Locale (java.util.Locale)8 Properties (java.util.Properties)6 HashMap (java.util.HashMap)4 Entry (java.util.Map.Entry)4 I18nModule (org.olat.core.util.i18n.I18nModule)4 Preferences (org.olat.core.util.prefs.Preferences)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)2 ProgressBar (org.olat.core.gui.components.progressbar.ProgressBar)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2