|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface I_CmsMessageBundle
Utility interface for generating localized messages for internal OpenCms operations.
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 a Locale
.
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 a Locale
to localize these keys. If you have a I_CmsMessageBundle
,
you can use getBundleName()
to initialize a CmsMessages
instance
using CmsMessages.CmsMessages(String, Locale)
.CmsMessageContainer
: In some circumstances, you do not have a Locale
,
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. The CmsMessageContainer
contains a reference to a I_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
of CmsMessages
. A key lookup is automatically done in all the CmsMessages
instances contained in the multi message instance, and the first match is returned.
Method Summary | |
---|---|
CmsMessageContainer |
container(java.lang.String key)
Creates a message container for this package with the given arguments. |
CmsMessageContainer |
container(java.lang.String key,
java.lang.Object arg0)
Creates a message container for this package with the given arguments. |
CmsMessageContainer |
container(java.lang.String key,
java.lang.Object[] args)
Creates a message container for this package with the given arguments. |
CmsMessageContainer |
container(java.lang.String key,
java.lang.Object arg0,
java.lang.Object arg1)
Creates a message container for this package with the given arguments. |
CmsMessageContainer |
container(java.lang.String key,
java.lang.Object arg0,
java.lang.Object arg1,
java.lang.Object arg2)
Creates a message container for this package with the given arguments. |
CmsMessages |
getBundle()
Returns the localized message bundle wrapped in this instance initialized with the OpenCms default locale. |
CmsMessages |
getBundle(java.util.Locale locale)
Returns the localized message bundle wrapped in this instance initialized with the provided locale. |
java.lang.String |
getBundleName()
Returns the bundle name for this OpenCms package. |
Method Detail |
---|
CmsMessageContainer container(java.lang.String key)
Convenience method for a message with no arguments.
key
- the message key to use
CmsMessageContainer container(java.lang.String key, java.lang.Object arg0)
Convenience method for a message with one argument.
key
- the message key to usearg0
- the message argument
CmsMessageContainer container(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1)
Convenience method for a message with two arguments.
key
- the message key to usearg0
- the first message argumentarg1
- the second message argument
CmsMessageContainer container(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
Convenience method for a message with three arguments.
key
- the message key to usearg0
- the first message argumentarg1
- the second message argumentarg2
- the third message argument
CmsMessageContainer container(java.lang.String key, java.lang.Object[] args)
key
- the message key to useargs
- the message arguments to use
CmsMessages getBundle()
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)
.
CmsMessages getBundle(java.util.Locale locale)
locale
- the locale to use
java.lang.String getBundleName()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |