Class CmsMessages
java.util.ResourceBundle
and provides convenience methods to access the Strings from a template.- Since:
- 8.0.0
- See Also:
-
CmsMessages
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatMessage
(String result, Object... args) Helper method for formatting message parameters.static String
formatUnknownKey
(String keyName) Formats an unknown key.Returns the localized message bundle wrapped in this instance.Returns the name of the resource bundle.getDate
(long time) Returns a formated date String from a timestamp value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.Returns a formated date String from a Date value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.getDate
(Date date, CmsDateTimeUtil.Format format) Returns a formated date String from a Date value, the formatting based on the provided option and the locale based on this instance.getDateTime
(long time) Returns a formated date and time String from a timestamp value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.getDateTime
(Date date) Returns a formated date and time String from a Date value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.getDateTime
(Date date, CmsDateTimeUtil.Format format) Returns a formated date and time String from a Date value, the formatting based on the provided option and the locale based on this instance.com.google.gwt.i18n.client.Dictionary
Returns the internal dictionary.static boolean
isUnknownKey
(String value) Returnstrue
if the provided value matches the scheme"??? " + keyName + " ???"
, that is the value appears to be an unknown key.Returns the localized resource string for a given message key.Returns the localized resource string for a given message key.Returns the selected localized message for the initialized resource bundle and locale.keyDefault
(String keyName, String defaultValue) Returns the localized resource string for a given message key.keyWithParams
(String keyName) Returns the localized resource string for a given message key, treating all values appended with "|" as replacement parameters.
-
Field Details
-
KEY_SHORT_SUFFIX
The suffix of a "short" localized key name.- See Also:
-
UNKNOWN_KEY_EXTENSION
Prefix / Suffix for unknown keys.- See Also:
-
-
Constructor Details
-
CmsMessages
Default constructor.- Parameters:
bundleName
- the localized bundle name
-
-
Method Details
-
formatMessage
Helper method for formatting message parameters.- Parameters:
result
- the raw message containing placeholders like {0}args
- the parameters to insert into the placeholders- Returns:
- the formatted message
-
formatUnknownKey
Formats an unknown key.- Parameters:
keyName
- the key to format- Returns:
- the formatted unknown key
- See Also:
-
isUnknownKey
Returnstrue
if the provided value matches the scheme"??? " + keyName + " ???"
, that is the value appears to be an unknown key.Also returns
true
if the given value isnull
.- Parameters:
value
- the value to check- Returns:
- true if the value is matches the scheme for unknown keys
- See Also:
-
getBundle
Returns the localized message bundle wrapped in this instance.Mainly for API compatibility with the core localization methods.
- Returns:
- the localized message bundle wrapped in this instance
-
getBundleName
Returns the name of the resource bundle.- Returns:
- the name of the resource bundle
-
getDate
Returns a formated date String from a Date value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.- Parameters:
date
- the Date object to format as String- Returns:
- the formatted date
-
getDate
Returns a formated date String from a Date value, the formatting based on the provided option and the locale based on this instance.- Parameters:
date
- the Date object to format as Stringformat
- the format to use, seeCmsDateTimeUtil.Format
for possible values- Returns:
- the formatted date
-
getDate
Returns a formated date String from a timestamp value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.- Parameters:
time
- the time value to format as date- Returns:
- the formatted date
-
getDateTime
Returns a formated date and time String from a Date value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.- Parameters:
date
- the Date object to format as String- Returns:
- the formatted date and time
-
getDateTime
Returns a formated date and time String from a Date value, the formatting based on the provided option and the locale based on this instance.- Parameters:
date
- the Date object to format as Stringformat
- the format to use, seeCmsDateTimeUtil.Format
for possible values- Returns:
- the formatted date and time
-
getDateTime
Returns a formated date and time String from a timestamp value, the format beingCmsDateTimeUtil.Format.SHORT
and the locale based on this instance.- Parameters:
time
- the time value to format as date- Returns:
- the formatted date and time
-
getDictionary
Returns the internal dictionary.- Returns:
- the internal dictionary
-
key
Returns the localized resource string for a given message key.If the key was not found in the bundle, the return value is
"??? " + keyName + " ???"
. This will also be returned if the bundle was not properly initialized first.- Parameters:
keyName
- the key for the desired string- Returns:
- the resource string for the given key
-
key
Returns the localized resource string for a given message key.If the key was not found in the bundle, the return value depends on the setting of the allowNull parameter. If set to false, the return value is always a String in the format
"??? " + keyName + " ???"
. If set to true, null is returned if the key is not found. This will also be returned if the bundle was not properly initialized first.- Parameters:
keyName
- the key for the desired stringallowNull
- if true, 'null' is an allowed return value- Returns:
- the resource string for the given key
-
key
Returns the selected localized message for the initialized resource bundle and locale.If the key was found in the bundle, it will be formatted using a
using the provided parameters.MessageFormat
If the key was not found in the bundle, the return value is
"??? " + keyName + " ???"
. This will also be returned if the bundle was not properly initialized first.- Parameters:
key
- the message keyargs
- the message arguments- Returns:
- the selected localized message for the initialized resource bundle and locale
-
keyDefault
Returns the localized resource string for a given message key.If the key was not found in the bundle, the provided default value is returned.
- Parameters:
keyName
- the key for the desired stringdefaultValue
- the default value in case the key does not exist in the bundle- Returns:
- the resource string for the given key it it exists, or the given default if not
-
keyWithParams
Returns the localized resource string for a given message key, treating all values appended with "|" as replacement parameters.If the key was found in the bundle, it will be formatted using a
using the provided parameters. The parameters have to be appended to the key separated by a "|". For example, the keyNameMessageFormat
error.message|First|Second
would use the keyerror.message
with the parametersFirst
andSecond
. This would be the same as calling
.key(String, Object[])
If no parameters are appended with "|", this is the same as calling
.key(String)
If the key was not found in the bundle, the return value is
"??? " + keyName + " ???"
. This will also be returned if the bundle was not properly initialized first.- Parameters:
keyName
- the key for the desired string, optionally containing parameters appended with a "|"- Returns:
- the resource string for the given key
- See Also:
-