use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.
the class SingleKeyTranslatorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
// save new values
for (I18nRowBundle bundle : bundles) {
String newValue = textElements.get(bundle.getLanguageKey()).getValue();
// bundle.getLanguageKey() + ":: " + newValue);
for (String itemKey : this.i18nItemKeys) {
I18nItem item = i18nMng.getI18nItem(translatorBaseClass.getPackage().getName(), itemKey, bundle.getOverlayLocale());
i18nMng.saveOrUpdateI18nItem(item, newValue);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.core.util.i18n.I18nItem in project OpenOLAT by OpenOLAT.
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 klemens.
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 klemens.
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 klemens.
the class InlineTranslationInterceptHandlerController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
protected void event(UserRequest ureq, Component source, Event event) {
if (source == delegatingComponent) {
String bundle = ureq.getParameter(ARG_BUNDLE);
String key = ureq.getParameter(ARG_KEY);
// The argument ARG_IDENT is not used for dispatching right now
if (isLogDebugEnabled()) {
logDebug("Got event to launch inline translation tool for bundle::" + bundle + " and key::" + key, null);
}
if (StringHelper.containsNonWhitespace(bundle) && StringHelper.containsNonWhitespace(key)) {
// 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));
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);
if (i18nItems.isEmpty()) {
logError("Can not launch inline translation tool, bundle or key empty! bundle::" + bundle + " key::" + key, null);
} else {
// sort with priority
i18nMgr.sortI18nItems(i18nItems, true, true);
// 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)) {
i18nItemEditCtr.initialzeI18nitemAsCurrentItem(ureq, item);
break;
}
}
// Open in modal window
if (cmc != null)
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), "close", i18nItemEditCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
} else {
logError("Can not launch inline translation tool, bundle or key empty! bundle::" + bundle + " key::" + key, null);
}
}
}
Aggregations