net.sf.magicproject.ui.i18n
Class LanguageManager

java.lang.Object
  extended by net.sf.magicproject.ui.i18n.LanguageManager

public final class LanguageManager
extends java.lang.Object

LanguageManager.java Created on 23 janv. 2004

Since:
0.54.16, 0.54.17 in case of the main language didn't contain the specified, 0.54.18 language extension is no more $lang, but .lang to suit to key, we search in the secondary one linux users, and so sourceforge web hosting
Author:
Fabrice Daugan

Field Summary
static java.lang.String DEFAULT_LANGUAGE
          The default language used is case of error or undefined message if the user language
static java.lang.String LANGUAGE_EXTENSION
          The language extension
static java.util.Set<Language> languages
          Represents the available languages and their specifications
static java.lang.String LOCALE_LANGUAGE
          The locale language.
static java.lang.String PATH_ROOT
          The root directory where resourcebundles are located.
 
Method Summary
static Language getLanguage()
          Return the current language name.
static java.lang.String getNullString(java.lang.String key)
          Return the localised message.
static java.util.ResourceBundle getPrimaryBundle(java.lang.String root)
          Return a bundle corresponding to the specified language in the root.
static java.util.ResourceBundle getSecondaryBundle(java.lang.String root)
          Return resource bundle used if the main one did not contain a message in the user language
static java.lang.String getString(java.lang.String key)
          return the localised message.
static java.lang.String getString(java.lang.String key, java.lang.Object... parameters)
           
static void initLanguageManager(java.lang.String languageName)
          Load the preferred language, and set the language field
static void setLanguage(java.lang.String languageName)
          Set the language to use.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_ROOT

public static final java.lang.String PATH_ROOT
The root directory where resourcebundles are located.

See Also:
Constant Field Values

DEFAULT_LANGUAGE

public static final java.lang.String DEFAULT_LANGUAGE
The default language used is case of error or undefined message if the user language

See Also:
Constant Field Values

LOCALE_LANGUAGE

public static final java.lang.String LOCALE_LANGUAGE
The locale language.


LANGUAGE_EXTENSION

public static final java.lang.String LANGUAGE_EXTENSION
The language extension

See Also:
Constant Field Values

languages

public static java.util.Set<Language> languages
Represents the available languages and their specifications

Method Detail

getLanguage

public static Language getLanguage()
Return the current language name.

Returns:
the current language name.

initLanguageManager

public static void initLanguageManager(java.lang.String languageName)
Load the preferred language, and set the language field

Parameters:
languageName - the language name to use.

getPrimaryBundle

public static java.util.ResourceBundle getPrimaryBundle(java.lang.String root)
Return a bundle corresponding to the specified language in the root. If there is bundle suiting to the language, it returns the English one.

Parameters:
root - directory where the looked for bundle is located.
Returns:
a bundle corresponding to the specified language.

getSecondaryBundle

public static java.util.ResourceBundle getSecondaryBundle(java.lang.String root)
Return resource bundle used if the main one did not contain a message in the user language

Parameters:
root - directory where the looked for bundle is located.
Returns:
resource bundle used if the main one did not contain a message in the user language

getString

public static java.lang.String getString(java.lang.String key)
return the localised message.

Parameters:
key - the message key.
Returns:
the message associated to the key
Since:
0.54.17 in case of the main language didn't contain the specified key, we search in the secondary one

getNullString

public static java.lang.String getNullString(java.lang.String key)
Return the localised message.

Parameters:
key - the message key.
Returns:
the message associated to the key.null if the key has not been found.

getString

public static java.lang.String getString(java.lang.String key,
                                         java.lang.Object... parameters)
Parameters:
key - the message key.
parameters - the parameters to add to resourceBudle.
Returns:
the message associated to the key with replaced parameters.

setLanguage

public static void setLanguage(java.lang.String languageName)
Set the language to use.

Parameters:
languageName - the new language to use


Copyright © 2003-2007 Magic-Project. All Rights Reserved.