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, "");
}
}
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;
}
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);
}
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;
}
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." : ""));
}
Aggregations