Class UnicodeLanguageUtil
- Author:
- Brian Wing Shun Chan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale.static String
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale.static String
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale.static String
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale.static String
format
(ResourceBundle resourceBundle, String pattern, Object argument) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode.static String
format
(ResourceBundle resourceBundle, String pattern, Object[] arguments) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode.static String
format
(ResourceBundle resourceBundle, String pattern, Object[] arguments, boolean translateArguments) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode.static String
format
(ResourceBundle resourceBundle, String pattern, Object argument, boolean translateArguments) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper argument) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper[] arguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper[] arguments, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper argument, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
format
(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object argument, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale.static String
Returns the key's translation from the portal's resource bundle in unicode.static String
Returns the key's translation from the portal's resource bundle in unicode.static String
get
(ResourceBundle resourceBundle, String key) Returns the key's translation from the resource bundle in unicode.static String
get
(ResourceBundle resourceBundle, String key, String defaultValue) Returns the key's translation from the resource bundle in unicode.static String
Returns the key's translation from the portlet configuration in unicode, or from the portal's resource bundle if the portlet configuration is unavailable.static String
Returns the key's translation from the portlet configuration in unicode, or from the portal's resource bundle if the portlet configuration is unavailable.static String
getTimeDescription
(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds) Returns an exact localized description in unicode of the time interval (in milliseconds) in the largest unit possible.static String
getTimeDescription
(javax.servlet.http.HttpServletRequest httpServletRequest, Long milliseconds) Returns an exact localized description in unicode of the time interval (in milliseconds) in the largest unit possible.
-
Constructor Details
-
UnicodeLanguageUtil
public UnicodeLanguageUtil()
-
-
Method Details
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper argument) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the single argument to be substituted into the pattern and translated, if possible- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper argument, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the single argument to be substituted into the pattern and translated, if possibletranslateArguments
- whether the argument is translated- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper[] arguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the pattern and translated, if possible- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, LanguageWrapper[] arguments, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object argument) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the single argument to be substituted into the pattern and translated, if possible- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object argument, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the single argument to be substituted into the pattern and translated, if possibletranslateArguments
- whether the argument is translated- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the pattern and translated, if possible- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
public static String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments, boolean translateArguments) Returns the translated pattern in unicode using the current request's locale or, if the current request locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
locale
- the locale to translate topattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the argument to be substituted into the pattern- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(Locale locale, String pattern, Object argument, boolean translateArguments) Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
locale
- the locale to translate topattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.argument
- the argument to be substituted into the patterntranslateArguments
- whether the argument is translated- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
locale
- the locale to translate topattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the pattern- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
public static String format(Locale locale, String pattern, Object[] arguments, boolean translateArguments) Returns the translated pattern in unicode using the locale or, if the locale is not available, the server's default locale. If a translation for a given key does not exist, this method returns the requested key as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
locale
- the locale to translate topattern
- the key to look up in the current locale's resource file. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholders
-
format
Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode. If a translation for a given key does not exist, this method returns the requested key in unicode as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- the key to look up in the resource bundle. The key follows the standard Java resource specification.argument
- the argument to be substituted into the pattern- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
public static String format(ResourceBundle resourceBundle, String pattern, Object argument, boolean translateArguments) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode. If a translation for a given key does not exist, this method returns the requested key in unicode as the translation.The substitute placeholder (e.g.
{0}
) is replaced with the argument, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- the key to look up in the resource bundle. The key follows the standard Java resource specification.argument
- the argument to be substituted into the patterntranslateArguments
- whether the argument is translated- Returns:
- the translated pattern in unicode, with the argument substituted in for the pattern's placeholder
-
format
Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode. If a translation for a given key does not exist, this method returns the requested key in unicode as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- the key to look up in the resource bundle. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the pattern- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholder
-
format
public static String format(ResourceBundle resourceBundle, String pattern, Object[] arguments, boolean translateArguments) Returns the translated pattern in the resource bundle in unicode or, if the resource bundle is not available, the untranslated key in unicode. If a translation for a given key does not exist, this method returns the requested key in unicode as the translation.The substitute placeholders (e.g.
{0}
,{1}
,{2}
, etc.) are replaced with the arguments, following the standard JavaResourceBundle
notion of index based substitution.- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- the key to look up in the resource bundle. The key follows the standard Java resource specification.arguments
- the arguments to be substituted into the patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern in unicode, with the arguments substituted in for the pattern's placeholder
-
get
Returns the key's translation from the portlet configuration in unicode, or from the portal's resource bundle if the portlet configuration is unavailable.- Parameters:
httpServletRequest
- the request used to determine the key's context and localekey
- the translation key- Returns:
- the key's translation in unicode, or the unicode key if the translation is unavailable
-
get
public static String get(javax.servlet.http.HttpServletRequest httpServletRequest, String key, String defaultValue) Returns the key's translation from the portlet configuration in unicode, or from the portal's resource bundle if the portlet configuration is unavailable.- Parameters:
httpServletRequest
- the request used to determine the key's context and localekey
- the translation keydefaultValue
- the value to return if there is no matching translation- Returns:
- the key's translation in unicode, or the default value in unicode if the translation is unavailable
-
get
Returns the key's translation from the portal's resource bundle in unicode.- Parameters:
locale
- the key's localekey
- the translation key- Returns:
- the key's translation in unicode
-
get
Returns the key's translation from the portal's resource bundle in unicode.- Parameters:
locale
- the key's localekey
- the translation keydefaultValue
- the value to return if there is no matching translation- Returns:
- the key's translation in unicode, or the default value in unicode if the translation is unavailable
-
get
Returns the key's translation from the resource bundle in unicode.- Parameters:
resourceBundle
- the requested key's resource bundlekey
- the translation key- Returns:
- the key's translation in unicode
-
get
Returns the key's translation from the resource bundle in unicode.- Parameters:
resourceBundle
- the requested key's resource bundlekey
- the translation keydefaultValue
- the value to return if there is no matching translation- Returns:
- the key's translation in unicode, or the default value in unicode if the translation is unavailable
-
getTimeDescription
public static String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds) Returns an exact localized description in unicode of the time interval (in milliseconds) in the largest unit possible.For example, the following time intervals would be converted to the following time descriptions, using the English locale:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Parameters:
httpServletRequest
- the request used to determine the current localemilliseconds
- the time interval in milliseconds to describe- Returns:
- an exact localized description in unicode of the time interval in the largest unit possible
-
getTimeDescription
public static String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, Long milliseconds) Returns an exact localized description in unicode of the time interval (in milliseconds) in the largest unit possible.For example, the following time intervals would be converted to the following time descriptions, using the English locale:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Parameters:
httpServletRequest
- the request used to determine the current localemilliseconds
- the time interval in milliseconds to describe- Returns:
- an exact localized description in unicode of the time interval in the largest unit possible
-