info.magnolia.cms.i18n
Class MessagesManager

java.lang.Object
  extended by info.magnolia.cms.i18n.MessagesManager
Direct Known Subclasses:
DefaultMessagesManager

public abstract class MessagesManager
extends Object

From this class you get the i18n messages. You should pass a a request, but if you can't the getMessages method will handle it properly. The get() methods are easy to use.

Author:
philipp, molaschi

Field Summary
static String DEFAULT_BASENAME
          Use this basename if no other is provided.
static String FALLBACK_LOCALE
          Use this locale if no other provided.
static String FALLBACK_NODEDATA
          The name of the property to store the current system language.
static String I18N_CONFIG_PATH
          The node name where the configuration for i18n is stored.
static String LANGUAGES_NODE_NAME
          Under this node all the available languages are stored.
 
Constructor Summary
MessagesManager()
           
 
Method Summary
static String get(String key)
           
static String get(String key, Object[] args)
          Get a message with parameters inside: the value {0} must be a number.
abstract  Collection getAvailableLocales()
           
abstract  Locale getDefaultLocale()
           
static MessagesManager getInstance()
           
static Messages getMessages()
           
static Messages getMessages(Locale locale)
           
static Messages getMessages(String basename)
           
static Messages getMessages(String basename, Locale locale)
           
protected abstract  Messages getMessagesInternal(String basename, Locale locale)
           
static String getWithDefault(String key, Object[] args, String defaultMsg)
          Get a message with parameters inside: the value {0} must be a number.
static String getWithDefault(String key, String defaultMsg)
          Use a default string.
abstract  void init()
           
abstract  void reload()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FALLBACK_LOCALE

public static final String FALLBACK_LOCALE
Use this locale if no other provided.

See Also:
Constant Field Values

DEFAULT_BASENAME

public static final String DEFAULT_BASENAME
Use this basename if no other is provided.

See Also:
Constant Field Values

I18N_CONFIG_PATH

public static final String I18N_CONFIG_PATH
The node name where the configuration for i18n is stored.

See Also:
Constant Field Values

FALLBACK_NODEDATA

public static final String FALLBACK_NODEDATA
The name of the property to store the current system language.

See Also:
Constant Field Values

LANGUAGES_NODE_NAME

public static final String LANGUAGES_NODE_NAME
Under this node all the available languages are stored. They are showed in the user dialog.

See Also:
Constant Field Values
Constructor Detail

MessagesManager

public MessagesManager()
Method Detail

getInstance

public static MessagesManager getInstance()

getMessages

public static Messages getMessages()

getMessages

public static Messages getMessages(String basename)

getMessages

public static Messages getMessages(Locale locale)

getMessages

public static Messages getMessages(String basename,
                                   Locale locale)

get

public static String get(String key)

get

public static String get(String key,
                         Object[] args)
Get a message with parameters inside: the value {0} must be a number.

Parameters:
key - key to find
args - replacement strings
Returns:
message

getWithDefault

public static String getWithDefault(String key,
                                    String defaultMsg)
Use a default string.

Parameters:
key - key to find
defaultMsg - default message
Returns:
message

getWithDefault

public static String getWithDefault(String key,
                                    Object[] args,
                                    String defaultMsg)
Get a message with parameters inside: the value {0} must be a number. Use a default message.

Parameters:
key - key to find
args - replacement strings
defaultMsg - default message
Returns:
message

init

public abstract void init()

getAvailableLocales

public abstract Collection getAvailableLocales()

getDefaultLocale

public abstract Locale getDefaultLocale()

getMessagesInternal

protected abstract Messages getMessagesInternal(String basename,
                                                Locale locale)

reload

public abstract void reload()


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.