Interface I_CmsMessageBundle
- All Known Implementing Classes:
A_CmsMessageBundle
,DefaultReportMessages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
,Messages
Every OpenCms core packages should provide one class implementing this interface.
This class should be called Messages
and be a subclass of
. Moreover, the implementation
should contain a A_CmsMessageBundle
public static CmsMessageBundle#get()
method, that returns
an instance of the class. Also the implementation should contain public static members
for all available localized keys.
How to use localization in the OpenCms core:
There are 3 main ulitiliy classes that deal with localization. These are
I_CmsMessageBundle
(all classes that implement this interface): These classes describe a pointer to a resource bundle, but without providing aLocale
. So this is like a list of valid keys that can be localized, without the actual localization.CmsMessages
: This is a fully localized resource bundle, with a list of keys and aLocale
to localize these keys. If you have aI_CmsMessageBundle
, you can usegetBundleName()
to initialize aCmsMessages
instance usingCmsMessages(String, Locale)
.CmsMessageContainer
: In some circumstances, you do not have aLocale
, but you want to generate a message that contains certain parameters anyway. For example, in the deeper layers of the OpenCms core an issue may be generated, but you do not have a full user context available. TheCmsMessageContainer
contains a reference to aI_CmsMessageBundle
, plus the name of the key to use in the bundle, plus a list of (optional) parameters. This container is then passed "upwards" in the core until the GUI layer (usually the Workplace) is reached.CmsMultiMessages
: This is a convenience class that contains a set ofCmsMessages
. A key lookup is automatically done in all theCmsMessages
instances contained in the multi message instance, and the first match is returned.
- Since:
- 6.0.0
-
Method Summary
Modifier and TypeMethodDescriptionCreates a message container for this package with the given arguments.Creates a message container for this package with the given arguments.Creates a message container for this package with the given arguments.Creates a message container for this package with the given arguments.Creates a message container for this package with the given arguments.Returns the localized message bundle wrapped in this instance initialized with the OpenCms default locale.Returns the localized message bundle wrapped in this instance initialized with the provided locale.Returns the bundle name for this OpenCms package.
-
Method Details
-
container
Creates a message container for this package with the given arguments.Convenience method for a message with no arguments.
- Parameters:
key
- the message key to use- Returns:
- a message container for this package with the given arguments
-
container
Creates a message container for this package with the given arguments.Convenience method for a message with one argument.
- Parameters:
key
- the message key to usearg0
- the message argument- Returns:
- a message container for this package with the given arguments
-
container
Creates a message container for this package with the given arguments.Convenience method for a message with two arguments.
- Parameters:
key
- the message key to usearg0
- the first message argumentarg1
- the second message argument- Returns:
- a message container for this package with the given arguments
-
container
Creates a message container for this package with the given arguments.Convenience method for a message with three arguments.
- Parameters:
key
- the message key to usearg0
- the first message argumentarg1
- the second message argumentarg2
- the third message argument- Returns:
- a message container for this package with the given arguments
-
container
Creates a message container for this package with the given arguments.- Parameters:
key
- the message key to useargs
- the message arguments to use- Returns:
- a message container for this package with the given arguments
-
getBundle
Returns the localized message bundle wrapped in this instance initialized with the OpenCms default locale.This should be used only for logging and system output, not for generating GUI messages that the user can see. In this case, use
getBundle(Locale)
.- Returns:
- the localized message bundle wrapped in this instance initialized with the OpenCms default locale
-
getBundle
Returns the localized message bundle wrapped in this instance initialized with the provided locale.- Parameters:
locale
- the locale to use- Returns:
- the localized message bundle wrapped in this instance initialized with the provided locale
-
getBundleName
Returns the bundle name for this OpenCms package.- Returns:
- the bundle name for this OpenCms package
-