use of org.orcid.utils.UTF8Control in project ORCID-Source by ORCID.
the class BaseController method getJavascriptMessages.
@ModelAttribute("jsMessagesJson")
public String getJavascriptMessages(HttpServletRequest request) {
Locale locale = RequestContextUtils.getLocale(request);
org.orcid.pojo.Local lPojo = new org.orcid.pojo.Local();
lPojo.setLocale(locale.toString());
ResourceBundle definitiveProperties = ResourceBundle.getBundle("i18n/javascript", defaultLocale, new UTF8Control());
Map<String, String> definitivePropertyMap = OrcidStringUtils.resourceBundleToMap(definitiveProperties);
ResourceBundle resources = ResourceBundle.getBundle("i18n/javascript", locale, new UTF8Control());
Map<String, String> localPropertyMap = OrcidStringUtils.resourceBundleToMap(resources);
if (!defaultLocale.equals(locale)) {
for (String propertyKey : definitivePropertyMap.keySet()) {
String property = localPropertyMap.get(propertyKey);
if (StringUtils.isBlank(property)) {
localPropertyMap.put(propertyKey, definitivePropertyMap.get(propertyKey));
}
}
}
lPojo.setMessages(localPropertyMap);
String messages = "";
try {
messages = StringEscapeUtils.escapeEcmaScript(new ObjectMapper().writeValueAsString(lPojo));
} catch (IOException e) {
LOGGER.error("getJavascriptMessages error:" + e.toString(), e);
}
return messages;
}
use of org.orcid.utils.UTF8Control in project ORCID-Source by ORCID.
the class LocaleManagerImpl method getJavascriptMessages.
@Cacheable(value = "locale-messages", key = "#locale.toString().concat('-javascript')")
public org.orcid.pojo.Local getJavascriptMessages(Locale locale) {
org.orcid.pojo.Local lPojo = new org.orcid.pojo.Local();
lPojo.setLocale(locale.toString());
ResourceBundle resource = ResourceBundle.getBundle("i18n/javascript", locale, new UTF8Control());
lPojo.setMessages(OrcidStringUtils.resourceBundleToMap(resource));
return lPojo;
}
use of org.orcid.utils.UTF8Control in project ORCID-Source by ORCID.
the class LocaleManagerImpl method getCountries.
/*
* Get country names from i18n files
*/
@Cacheable(value = "locale-messages", key = "#locale.toString().concat('-countries-map')")
public Map<String, String> getCountries(Locale locale) {
ResourceBundle resource = ResourceBundle.getBundle("i18n/messages", locale, new UTF8Control());
Map<String, String> dbCountries = countryManager.retrieveCountriesAndIsoCodes();
Map<String, String> countries = new LinkedHashMap<String, String>();
for (String key : dbCountries.keySet()) {
countries.put(key, resource.getString(buildInternationalizationKey(CountryIsoEntity.class, key)));
}
FunctionsOverCollections.sortMapsByValues(countries);
return countries;
}
Aggregations