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

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 A_CmsMessageBundle. Moreover, the implementation should contain a 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(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.
Since:
6.0.0
  • 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 use
      arg0 - 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 use
      arg0 - the first message argument
      arg1 - 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 use
      arg0 - the first message argument
      arg1 - the second message argument
      arg2 - 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 use
      args - 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