public final class I18nUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
extractLanguageCode(String languageString,
String defaultLanguageCode)
Extracts the two letter language code defined in ISO 639 from a specified string.
|
static com.google.common.collect.ImmutableMap<String,String> |
flattenMap(Map<String,Map<String,String>> i18nMap,
String propertyPrefix,
String propertySeparator)
Flattens an i18n map to a map with a key based on the keys of the nested maps and a value of the defined property.
|
static <T extends Localizable<T>> |
localize(Collection<T> localizableCollection,
org.springframework.context.MessageSource messageSource,
Locale locale)
Localizes a list of localizable classes and returns the localized versions of the specified instances.
|
public static com.google.common.collect.ImmutableMap<String,String> flattenMap(Map<String,Map<String,String>> i18nMap, String propertyPrefix, String propertySeparator)
i18nMap
- the i18n map to flattenpropertyPrefix
- the prefix which is added before each key in the new mappropertySeparator
- the separator which is added between the map keyspublic static <T extends Localizable<T>> com.google.common.collect.ImmutableList<T> localize(Collection<T> localizableCollection, org.springframework.context.MessageSource messageSource, Locale locale)
T
- the localizable class which implements the Localizable
interfacelocalizableCollection
- the instances which needs to be localizedmessageSource
- the message source which translates the i18n codes for the localizationlocale
- the specified locale to which the i18n codes are translatedpublic static String extractLanguageCode(String languageString, String defaultLanguageCode)
languageString
- the string to get the two letter language codedefaultLanguageCode
- the default code which is returned if the languageString
is nullCopyright © 2010 - 2017 edorasware ag. All Rights Reserved.