net.sf.shineframework.common.i18n
Class Localizer

java.lang.Object
  extended by net.sf.shineframework.common.i18n.Localizer

public class Localizer
extends java.lang.Object

This class is responsible for the l10n. Any localized string in the system should be translated using this class.
The localizer class searches the classpath for a resource messagesBundle with the base name shinefw_messages. All the messages in the system are expected to be found in the single resource messagesBundle properties file.

Author:
amirk

Field Summary
static java.lang.String FORMATS_BUNDLE_NAME
           
static java.lang.String MESSAGES_BUNDLE_NAME
           
 
Constructor Summary
Localizer()
           
 
Method Summary
static java.lang.String format(java.lang.String patternName, java.lang.Object... params)
           
static java.lang.StringBuffer format(java.lang.String patternName, java.lang.StringBuffer result, java.util.Locale l, java.lang.Object... params)
           
static java.util.Locale getDefaultLocale()
           
static java.lang.String getMessage(java.lang.String key)
          Loads a message from a resource messagesBundle
static java.lang.String getMessage(java.lang.String key, java.util.Locale l)
          Loads a message from a resource messagesBundle
static java.lang.String getMessage(java.lang.String key, java.util.Locale l, java.lang.Object... params)
          Loads a message pattern from the resource messagesBundle and format it using the MessageFormat class
static java.lang.String getMessage(java.lang.String key, java.lang.Object... params)
           
static boolean isKeyExist(java.lang.String key)
          Checks if message exists
static boolean isKeyExist(java.lang.String key, java.util.Locale l)
          Checks if message exists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGES_BUNDLE_NAME

public static final java.lang.String MESSAGES_BUNDLE_NAME
See Also:
Constant Field Values

FORMATS_BUNDLE_NAME

public static final java.lang.String FORMATS_BUNDLE_NAME
See Also:
Constant Field Values
Constructor Detail

Localizer

public Localizer()
Method Detail

getDefaultLocale

public static java.util.Locale getDefaultLocale()
Returns:
Returns the defaultLocale.

isKeyExist

public static boolean isKeyExist(java.lang.String key)
Checks if message exists

Parameters:
key - the key of the message
Returns:
true or false

isKeyExist

public static boolean isKeyExist(java.lang.String key,
                                 java.util.Locale l)
Checks if message exists

Parameters:
key - the key of the message
Returns:
true or false

getMessage

public static java.lang.String getMessage(java.lang.String key)
Loads a message from a resource messagesBundle

Parameters:
key - the key of the message
Returns:
the message from the resource messagesBundle, or '@@@key@@@' if the key wasn't found on the messagesBundle

getMessage

public static java.lang.String getMessage(java.lang.String key,
                                          java.util.Locale l)
Loads a message from a resource messagesBundle

Parameters:
key - the key of the message
l - locale
Returns:
the message from the resource messagesBundle, or '@@@key@@@' if the key wasn't found on the messagesBundle

getMessage

public static java.lang.String getMessage(java.lang.String key,
                                          java.util.Locale l,
                                          java.lang.Object... params)
Loads a message pattern from the resource messagesBundle and format it using the MessageFormat class

Parameters:
key - the key of the message
params - the arguments to the message
l - locale
Returns:
the formated message, '@@@key@@@' if the key wasn't found on the resource messagesBundle

getMessage

public static java.lang.String getMessage(java.lang.String key,
                                          java.lang.Object... params)

format

public static java.lang.String format(java.lang.String patternName,
                                      java.lang.Object... params)

format

public static java.lang.StringBuffer format(java.lang.String patternName,
                                            java.lang.StringBuffer result,
                                            java.util.Locale l,
                                            java.lang.Object... params)


Copyright © 2007 sourceforge.net. All Rights Reserved.