|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.util.Localization
public class Localization
Facilitates internalization (i18n) and localization (l10n) of strings.
Locale-specific strings are stored in a single file in each package
named LocalStrings.properties,
LocalStrings_{locale}.properties or any other format supported by
ResourceBundle. This class supports two modes of localization:
getLocalization(String) method to create instances of the
Localization class for a specific package. Here, you use the
getString(String) and getString(String, Object...)
methods on the Localization instance you previously created.
getString(Class, String) and
getString(Class, String, Object...) static methods do not require
you to explicitly create a new Localization instance. In addition,
the keys are automatically prefixed with the class name. For example, if
your property file contains the following lines:
WindowA.title = First Title WindowB.title = Second TitleYou can read each entry with
Localization.getString(WindowA.class, "title") and
Localization.getString(WindowB.class, "title"). This is convenient
for providing localization in subclasses by using the getClass()
method.
| Method Summary | |
|---|---|
static boolean |
containsKey(Class<?> type,
String key)
Returns true if a localized string exists for the given key;
false otherwise. |
boolean |
containsKey(String key)
Returns true if a localized string exists for the given key;
false otherwise. |
ResourceBundle |
getBundle()
Returns the underlying resource bundle. |
Locale |
getLocale()
Returns the locale of this localization. |
static Localization |
getLocalization(Class<?> type)
Returns the localization object for the given class. |
static Localization |
getLocalization(Class<?> type,
Locale locale)
Returns the localization object for the given class and locale. |
static Localization |
getLocalization(String packageName)
Returns the localization object for the given package. |
static Localization |
getLocalization(String packageName,
Locale locale)
Returns the localization object for the given package and locale. |
static String |
getString(Class<?> type,
String key)
Returns the localized string for the given key. |
static String |
getString(Class<?> type,
String key,
Object... arguments)
Returns the localized string for the given key and formatting arguments. |
String |
getString(String key)
Returns the localized string for the given key. |
String |
getString(String key,
Object... arguments)
Returns the localized string for the given key and formatting arguments. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public ResourceBundle getBundle()
public Locale getLocale()
public String getString(String key)
key - the key for the desired string
public boolean containsKey(String key)
true if a localized string exists for the given key;
false otherwise.
key - the key for the desired string
true if a localized string exists for the given key;
false otherwise
public String getString(String key,
Object... arguments)
MessageFormat for formatting the arguments. If
the key is not found, then this methods returns the key itself.
key - the key for the desired stringarguments - the formatting arguments
public static Localization getLocalization(String packageName)
packageName - the name of the package
public static Localization getLocalization(String packageName,
Locale locale)
packageName - the name of the packagelocale - the target locale
public static Localization getLocalization(Class<?> type)
type - the class requesting the localization object
public static Localization getLocalization(Class<?> type,
Locale locale)
type - the class requesting the localization objectlocale - the target locale
public static boolean containsKey(Class<?> type,
String key)
true if a localized string exists for the given key;
false otherwise. This method automatically finds the correct
resource bundle and key prefix appropriate for the class.
type - the class requesting the localized stringkey - the key (minus the class prefix)
true if a localized string exists for the given key;
false otherwise
public static String getString(Class<?> type,
String key)
Localization.getString(MainGUI.class, "title") returns the
localized string for the key "MainGUI.title".
type - the class requesting the localized stringkey - the key (minus the class prefix)
public static String getString(Class<?> type,
String key,
Object... arguments)
Localization.getString(MainGUI.class, "title") returns the
localized string for the key "MainGUI.title".
type - the class requesting the localized stringkey - the key (minus the class prefix)arguments - the formatting arguments
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||