private 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); }
public void renameLanguageTask(Locale sourceLocale, Locale targetLocale) { // check if targetLocale exists already Set<String> allLangKeys = I18nModule.getAvailableLanguageKeys(); if (allLangKeys.contains(targetLocale.getLanguage())) { log.error("Target Language " + targetLocale.getLanguage() + " already exists! "); } else { // get All items from sourceLocale, copy to targetLocale and delete sourceLocale List<I18nItem> items = i18nMgr.findExistingI18nItems(sourceLocale, null, true); for (I18nItem item : items) { String bundleName = item.getBundleName(); String itemKey = item.getKey(); I18nItem targetTempItem = new I18nItem( bundleName, itemKey, targetLocale, item.getBundlePriority(), item.getKeyPriority()); Properties prop = i18nMgr.getPropertiesWithoutResolvingRecursively(sourceLocale, bundleName); String value = prop.getProperty(itemKey); i18nMgr.saveOrUpdateI18nItem(targetTempItem, value); deleteKey(sourceLocale, bundleName, itemKey); } } }