Package com.saperion.ngc.util
Class LocalizationUtil
java.lang.Object
com.saperion.ngc.util.LocalizationUtil
- All Implemented Interfaces:
- Serializable
Utility class for localization.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringName of the attribute used to store this utility in the zk-webapp.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor that is called by web application init listener.
- 
Method SummaryModifier and TypeMethodDescriptionprotected StringcacheLocalize(String toLocalize, Locale clientLocale) coreLocalize(String key) Localize a core string using thestringsresource bundle.coreLocalize(String key, jakarta.servlet.http.HttpSession session) Localize a core string using thestringsresource bundle.databaseLocalize(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.Returns a list of all supported locales as configured in webclient.properties.static LocaleGets the current locale.static LocalegetCurrentLocale(jakarta.servlet.http.HttpSession session) Gets the current locale.static Localeresolve defaultLocale form web.xml.static StringGet current Display Language in english.static LocalizationUtilGet LocalizationUtil Instance.static LocalizationUtilgetInstanceExternal(jakarta.servlet.ServletContext context) Get LocalizationUtil Instance.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.getSupportedLocale(jakarta.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.Deprecated.booleanisSupportedLocale(Locale locale) Checks if the specified locale is supported.static StringLocalize the key with the given localization bundle.localizeFolderPath(String pathToLocalize) Localizes a folder path.static LocaleresolveLocale(String webLocale) resolve Country and Language from a Locale String like "de_DE".static StringresolveLocale(Locale locale) resolve Country and Language from a Locale to a String like "de_DE".resolveToStringArray(String valuesConcatinated) Deprecated.will be removed in 8.1static StringsessionLocalize(String key) Returns the session stored messages by the given key if existing.static voidsetCurrentLocale(Locale aLocale) static voidsetCurrentLocale(Locale aLocale, jakarta.servlet.http.HttpSession session) static StringstaticWebLocalize(String key) Localize a string using thelocalizationsresource bundle.webLocalize(String key) Localize a string using thelocalizationsresource bundle.webLocalize(String key, jakarta.servlet.http.HttpSession session) Localize a string using thelocalizationsresource bundle.
- 
Field Details- 
WEB_APP_ATTRName of the attribute used to store this utility in the zk-webapp.- See Also:
 
 
- 
- 
Constructor Details- 
LocalizationUtilpublic LocalizationUtil()Constructor that is called by web application init listener. To get a LocalizationUtil instance, use the getInstance or getInstanceExternal methods.
 
- 
- 
Method Details- 
getCurrentLocaleGets the current locale.- Returns:
- the current locale
 
- 
getCurrentLocaleGets the current locale. Uses the specified session to read attributes from.- Parameters:
- session- the session
- Returns:
- the current locale
 
- 
setCurrentLocale- Parameters:
- aLocale- the currentLocale to set
 
- 
setCurrentLocale- Parameters:
- aLocale- the currentLocale to set
 
- 
getDisplayLanguageGet current Display Language in english.- Returns:
- the displayLanguage
 
- 
getInstanceGet LocalizationUtil Instance.- Returns:
- LocalizationUtil
 
- 
getInstanceExternalGet LocalizationUtil Instance. Can be called from without ZK context.- Parameters:
- context- current servlet context
- Returns:
- LocalizationUtil
 
- 
webLocalizeLocalize a string using thelocalizationsresource bundle. Use this method to localize keys fromLocalizationConstants.- Parameters:
- key- Key
- Returns:
- Localized string
 
- 
staticWebLocalizeLocalize 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
 
- 
webLocalizeLocalize a string using thelocalizationsresource bundle. Use this method to localize keys fromLocalizationConstants.- Parameters:
- key- Key
- session- the current session
- Returns:
- Localized string
 
- 
sessionLocalizeReturns 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.
 
- 
coreLocalizeLocalize a core string using thestringsresource bundle. Use this method to localize a key fromCoreResources.- Parameters:
- key- Key
- Returns:
- Localized key
 
- 
coreLocalizeLocalize a core string using thestringsresource bundle. Use this method to localize a key fromCoreResources.- Parameters:
- key- Key
- session- the current session
- Returns:
- Localized key
 
- 
databaseLocalizeLocalizes 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 String localize(String baseName, String key, jakarta.servlet.http.HttpSession session) Localize the key with the given localization bundle.- Parameters:
- baseName- Bundle name
- key- Key
- session- Session
- Returns:
- Localized value
 
- 
cacheLocalizeprotected String cacheLocalize(String toLocalize, 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
 
- 
localizeFolderPathLocalizes a folder path.- Parameters:
- pathToLocalize- path to localize
- Returns:
- localized path
 
- 
resolveLocaleresolve Country and Language from a Locale String like "de_DE".- Parameters:
- webLocale- webLocale
- Returns:
- locale Locale
 
- 
resolveLocaleresolve Country and Language from a Locale to a String like "de_DE".- Parameters:
- locale- locale
- Returns:
- locale String
 
- 
resolveToStringArrayDeprecated.will be removed in 8.1resolve values concatinated Strings seperated with "," to an ArrayList .- Parameters:
- valuesConcatinated- valuesConcatinated
- Returns:
- arraylist resultArray
 
- 
getSupportedLocalesDeprecated.usegetAllSupportedLocales()instead. Will be removed in 8.1resolve supportedLocales form web.xml.- Returns:
- supportedLocales resultArray
 
- 
getAllSupportedLocalesReturns a list of all supported locales as configured in webclient.properties. The returned list is not modifiable.- Returns:
- list of supported locales
 
- 
getDefaultLocaleresolve defaultLocale form web.xml.- Returns:
- supportedLocales resultArray
 
- 
isSupportedLocaleChecks if the specified locale is supported.- Parameters:
- locale- locale to check
- Returns:
- true if the specified locale is supported, otherwise false
 
- 
getSupportedLocaleCheck 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
 
- 
getSupportedLocaleCheck 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
 
 
- 
getAllSupportedLocales()instead.