public void fillDataObject(Data data, String[] attributes, Document doc) { data.set(Field.UID, doc.getUID()); Locale[] locales = LanguageUtil.getAvailableLocales().toArray( new Locale[0]); Locale siteLocale = LocaleUtil.getSiteDefault(); for (String attribute : attributes) { String attrDoc = ConfigurationUtil.getIndexAttributeName( data.getModel(), attribute); List<Map<Locale, String>> listValueMap = null; Class<?> typeClass = data.getAttributeClass(attribute); if (typeClass.equals(String.class) || typeClass.equals(Object.class)) { listValueMap = getLocalizedMap(locales, doc, attrDoc); } if ((listValueMap != null) && !listValueMap.isEmpty()) { String[] xml = new String[listValueMap.size()]; int pos = 0; for (Map<Locale, String> valueMap : listValueMap) { xml[pos++] = LocalizationUtil.updateLocalization( valueMap, "", "data", LocaleUtil.toLanguageId(siteLocale)); } data.set(attribute, xml); } else if (doc.hasField(attrDoc)) { data.set(attribute, doc.getField(attrDoc).getValues()); } } }
public void setTitle(String title, Locale locale, Locale defaultLocale) { String languageId = LocaleUtil.toLanguageId(locale); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); if (Validator.isNotNull(title)) { setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title", title, languageId, defaultLanguageId)); } else { setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title", languageId)); } }
public void setDescription(String description, Locale locale, Locale defaultLocale) { String languageId = LocaleUtil.toLanguageId(locale); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); if (Validator.isNotNull(description)) { setDescription(LocalizationUtil.updateLocalization( getDescription(), "Description", description, languageId, defaultLanguageId)); } else { setDescription(LocalizationUtil.removeLocalization( getDescription(), "Description", languageId)); } }
public void setDiplomaTemplate(String diplomaTemplate, Locale locale, Locale defaultLocale) { String languageId = LocaleUtil.toLanguageId(locale); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); if (Validator.isNotNull(diplomaTemplate)) { setDiplomaTemplate(LocalizationUtil.updateLocalization( getDiplomaTemplate(), "DiplomaTemplate", diplomaTemplate, languageId, defaultLanguageId)); } else { setDiplomaTemplate(LocalizationUtil.removeLocalization( getDiplomaTemplate(), "DiplomaTemplate", languageId)); } }
protected void updateThreadPriorities(ActionRequest actionRequest) throws Exception { Locale[] locales = LanguageUtil.getAvailableLocales(); for (int i = 0; i < locales.length; i++) { String languageId = LocaleUtil.toLanguageId(locales[i]); List<String> priorities = new ArrayList<String>(); for (int j = 0; j < 10; j++) { String name = ParamUtil.getString( actionRequest, "priorityName" + j + "_" + languageId); String image = ParamUtil.getString( actionRequest, "priorityImage" + j + "_" + languageId); double value = ParamUtil.getDouble( actionRequest, "priorityValue" + j + "_" + languageId); if (Validator.isNotNull(name) || Validator.isNotNull(image) || (value != 0.0)) { priorities.add( name + StringPool.COMMA + image + StringPool.COMMA + value); } } String preferenceName = LocalizationUtil.getPreferencesKey( "priorities", languageId); setPreference( actionRequest, preferenceName, priorities.toArray(new String[priorities.size()])); } }
public static String getLocalizedContent(String content) { return LocalizationUtil.updateLocalization( StringPool.BLANK, "static-content" ,content); }
public static Map<Locale, String> getLocalizationMap(String content) { return LocalizationUtil.getLocalizationMap(content); }
public String getTitle(String languageId) { return LocalizationUtil.getLocalization(getTitle(), languageId); }
public String getTitle(String languageId, boolean useDefault) { return LocalizationUtil.getLocalization(getTitle(), languageId, useDefault); }
public Map<Locale, String> getTitleMap() { return LocalizationUtil.getLocalizationMap(getTitle()); }
public String getDescription(String languageId) { return LocalizationUtil.getLocalization(getDescription(), languageId); }
public String getDescription(String languageId, boolean useDefault) { return LocalizationUtil.getLocalization(getDescription(), languageId, useDefault); }
public Map<Locale, String> getDescriptionMap() { return LocalizationUtil.getLocalizationMap(getDescription()); }
public String getDiplomaTemplate(String languageId) { return LocalizationUtil.getLocalization(getDiplomaTemplate(), languageId); }
public String getDiplomaTemplate(String languageId, boolean useDefault) { return LocalizationUtil.getLocalization(getDiplomaTemplate(), languageId, useDefault); }
public Map<Locale, String> getDiplomaTemplateMap() { return LocalizationUtil.getLocalizationMap(getDiplomaTemplate()); }