Package com.saperion.ngc.util
Class LocalizationUtil
- java.lang.Object
- 
- com.saperion.ngc.util.LocalizationUtil
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 public class LocalizationUtil extends java.lang.Object implements java.io.SerializableUtility class for localization.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringWEB_APP_ATTRName of the attribute used to store this utility in the zk-webapp.
 - 
Constructor SummaryConstructors Constructor Description LocalizationUtil()Constructor that is called by web application init listener.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.lang.StringcacheLocalize(java.lang.String toLocalize, java.util.Locale clientLocale)java.lang.StringcoreLocalize(java.lang.String key)Localize a core string using thestringsresource bundle.java.lang.StringcoreLocalize(java.lang.String key, javax.servlet.http.HttpSession session)Localize a core string using thestringsresource bundle.java.lang.StringdatabaseLocalize(java.lang.String toLocalize)Localizes a string for the current client locale using the localize table on the database and a localizeUtilCache for holding localized Strings in a cache.java.util.List<java.util.Locale>getAllSupportedLocales()Returns a list of all supported locales as configured in webclient.properties.static java.util.LocalegetCurrentLocale()Gets the current locale.static java.util.LocalegetCurrentLocale(javax.servlet.http.HttpSession session)Gets the current locale.static java.util.LocalegetDefaultLocale()resolve defaultLocale form web.xml.static java.lang.StringgetDisplayLanguage()Get current Display Language in english.static LocalizationUtilgetInstance()Get LocalizationUtil Instance.static LocalizationUtilgetInstanceExternal(javax.servlet.ServletContext context)Get LocalizationUtil Instance.java.util.LocalegetSupportedLocale()Check if the initial browser Locale or current Locale is one of the supported Locales.If this Locale is not supported we use the defaultLocale.java.util.LocalegetSupportedLocale(javax.servlet.http.HttpSession session)Check if the initial browser Locale or current Locale is one of the supported Locales.If this Locale is not supported we use the defaultLocale.java.util.ArrayList<java.util.Locale>getSupportedLocales()Deprecated.usegetAllSupportedLocales()instead.booleanisSupportedLocale(java.util.Locale locale)Checks if the specified locale is supported.static java.lang.Stringlocalize(java.lang.String baseName, java.lang.String key, javax.servlet.http.HttpSession session)Localize the key with the given localization bundle.java.lang.StringlocalizeFolderPath(java.lang.String pathToLocalize)Localizes a folder path.static java.util.LocaleresolveLocale(java.lang.String webLocale)resolve Country and Language from a Locale String like "de_DE".static java.lang.StringresolveLocale(java.util.Locale locale)resolve Country and Language from a Locale to a String like "de_DE".static java.util.ArrayList<java.lang.String>resolveToStringArray(java.lang.String valuesConcatinated)Deprecated.will be removed in 8.1static java.lang.StringsessionLocalize(java.lang.String key)Returns the session stored messages by the given key if existing.static voidsetCurrentLocale(java.util.Locale aLocale)static voidsetCurrentLocale(java.util.Locale aLocale, javax.servlet.http.HttpSession session)static java.lang.StringstaticWebLocalize(java.lang.String key)Localize a string using thelocalizationsresource bundle.java.lang.StringwebLocalize(java.lang.String key)Localize a string using thelocalizationsresource bundle.java.lang.StringwebLocalize(java.lang.String key, javax.servlet.http.HttpSession session)Localize a string using thelocalizationsresource bundle.
 
- 
- 
- 
Field Detail- 
WEB_APP_ATTRpublic static final java.lang.String WEB_APP_ATTR Name of the attribute used to store this utility in the zk-webapp.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getCurrentLocalepublic static java.util.Locale getCurrentLocale() Gets the current locale.- Returns:
- the current locale
 
 - 
getCurrentLocalepublic static java.util.Locale getCurrentLocale(javax.servlet.http.HttpSession session) Gets the current locale. Uses the specified session to read attributes from.- Parameters:
- session- the session
- Returns:
- the current locale
 
 - 
setCurrentLocalepublic static void setCurrentLocale(java.util.Locale aLocale) - Parameters:
- aLocale- the currentLocale to set
 
 - 
setCurrentLocalepublic static void setCurrentLocale(java.util.Locale aLocale, javax.servlet.http.HttpSession session)- Parameters:
- aLocale- the currentLocale to set
 
 - 
getDisplayLanguagepublic static java.lang.String getDisplayLanguage() Get current Display Language in english.- Returns:
- the displayLanguage
 
 - 
getInstancepublic static LocalizationUtil getInstance() Get LocalizationUtil Instance.- Returns:
- LocalizationUtil
 
 - 
getInstanceExternalpublic static LocalizationUtil getInstanceExternal(javax.servlet.ServletContext context) Get LocalizationUtil Instance. Can be called from without ZK context.- Parameters:
- context- current servlet context
- Returns:
- LocalizationUtil
 
 - 
webLocalizepublic java.lang.String webLocalize(java.lang.String key) Localize a string using thelocalizationsresource bundle. Use this method to localize keys fromLocalizationConstants.- Parameters:
- key- Key
- Returns:
- Localized string
 
 - 
staticWebLocalizepublic static java.lang.String staticWebLocalize(java.lang.String key) Localize a string using thelocalizationsresource bundle. Use this method to localize keys fromLocalizationConstants. Same as webLocalize but accessible from static methods.- Parameters:
- key- Key
- Returns:
- Localized string
 
 - 
webLocalizepublic java.lang.String webLocalize(java.lang.String key, javax.servlet.http.HttpSession session)Localize a string using thelocalizationsresource bundle. Use this method to localize keys fromLocalizationConstants.- Parameters:
- key- Key
- session- the current session
- Returns:
- Localized string
 
 - 
sessionLocalizepublic static java.lang.String sessionLocalize(java.lang.String key) Returns the session stored messages by the given key if existing. Returns null if no session is available or no message with the given key exists in the session. Session based messages are stored byServiceView.registerSessionAttributes.- Parameters:
- key- The key of the message to retrieve.
- Returns:
- The requested message or null if no session is available no message exists by the given key.
 
 - 
coreLocalizepublic java.lang.String coreLocalize(java.lang.String key) Localize a core string using thestringsresource bundle. Use this method to localize a key fromCoreResources.- Parameters:
- key- Key
- Returns:
- Localized key
 
 - 
coreLocalizepublic java.lang.String coreLocalize(java.lang.String key, javax.servlet.http.HttpSession session)Localize a core string using thestringsresource bundle. Use this method to localize a key fromCoreResources.- Parameters:
- key- Key
- session- the current session
- Returns:
- Localized key
 
 - 
databaseLocalizepublic java.lang.String databaseLocalize(java.lang.String toLocalize) Localizes a string for the current client locale using the localize table on the database and a localizeUtilCache for holding localized Strings in a cache. If the cache is not activated (configurable in web.xml) the standard localization handling is used instead.- Parameters:
- toLocalize- string to localize
- Returns:
- localized string or the original string if no localized string was found
 
 - 
localizepublic static java.lang.String localize(java.lang.String baseName, java.lang.String key, javax.servlet.http.HttpSession session)Localize the key with the given localization bundle.- Parameters:
- baseName- Bundle name
- key- Key
- session- Session
- Returns:
- Localized value
 
 - 
cacheLocalizeprotected java.lang.String cacheLocalize(java.lang.String toLocalize, java.util.Locale clientLocale) throws com.saperion.cache.exception.CacheException, com.saperion.cache.exception.ElementNotFoundException, com.saperion.cache.exception.CorruptElementException- Throws:
- com.saperion.cache.exception.CacheException
- com.saperion.cache.exception.ElementNotFoundException
- com.saperion.cache.exception.CorruptElementException
 
 - 
localizeFolderPathpublic java.lang.String localizeFolderPath(java.lang.String pathToLocalize) Localizes a folder path.- Parameters:
- pathToLocalize- path to localize
- Returns:
- localized path
 
 - 
resolveLocalepublic static java.util.Locale resolveLocale(java.lang.String webLocale) resolve Country and Language from a Locale String like "de_DE".- Parameters:
- webLocale- webLocale
- Returns:
- locale Locale
 
 - 
resolveLocalepublic static java.lang.String resolveLocale(java.util.Locale locale) resolve Country and Language from a Locale to a String like "de_DE".- Parameters:
- locale- locale
- Returns:
- locale String
 
 - 
resolveToStringArray@Deprecated public static java.util.ArrayList<java.lang.String> resolveToStringArray(java.lang.String valuesConcatinated) Deprecated.will be removed in 8.1resolve values concatinated Strings seperated with "," to an ArrayList .- Parameters:
- valuesConcatinated- valuesConcatinated
- Returns:
- arraylist resultArray
 
 - 
getSupportedLocales@Deprecated public java.util.ArrayList<java.util.Locale> getSupportedLocales() Deprecated.usegetAllSupportedLocales()instead. Will be removed in 8.1resolve supportedLocales form web.xml.- Returns:
- supportedLocales resultArray
 
 - 
getAllSupportedLocalespublic java.util.List<java.util.Locale> getAllSupportedLocales() Returns a list of all supported locales as configured in webclient.properties. The returned list is not modifiable.- Returns:
- list of supported locales
 
 - 
getDefaultLocalepublic static java.util.Locale getDefaultLocale() resolve defaultLocale form web.xml.- Returns:
- supportedLocales resultArray
 
 - 
isSupportedLocalepublic boolean isSupportedLocale(java.util.Locale locale) Checks if the specified locale is supported.- Parameters:
- locale- locale to check
- Returns:
- true if the specified locale is supported, otherwise false
 
 - 
getSupportedLocalepublic java.util.Locale getSupportedLocale() Check if the initial browser Locale or current Locale is one of the supported Locales.If this Locale is not supported we use the defaultLocale.- Returns:
- supportedLocale
 
 - 
getSupportedLocalepublic java.util.Locale getSupportedLocale(javax.servlet.http.HttpSession session) Check if the initial browser Locale or current Locale is one of the supported Locales.If this Locale is not supported we use the defaultLocale.- Parameters:
- session- the current session
- Returns:
- supportedLocale
 
 
- 
 
-