jimm.util
Class I18N

java.lang.Object
  extended by jimm.util.I18N

public class I18N
extends java.lang.Object

This class finds the local version of any string. It also contains a method for changing the language.

Each language should have a file called datavision_XX_YY.properties, where XX is the language code (e.g., "en" for English, "fr" for French) and YY is the country code (e.g., "US", "FR").

Author:
Jim Menard, jimm@io.com

Field Summary
protected static java.util.HashMap bundles
           
protected static java.util.Locale locale
           
static java.lang.String MENU_FILE_PREFIX
           
static java.lang.String PAPER_FILE_PREFIX
           
static java.lang.String RESOURCE_FILE_PREFIX
           
 
Constructor Summary
I18N()
           
 
Method Summary
static java.lang.String get(java.lang.String key)
          Returns the string corresponding to the specified string.
static java.lang.String get(java.lang.String prefix, java.lang.String key)
          Returns the string corresponding to the specified string in the bundle file corresponding to the name prefix.
protected static java.util.ResourceBundle getBundle(java.lang.String prefix)
           
static java.lang.String getNullIfMissing(java.lang.String key)
          Returns the string corresponding to the specified string.
static java.lang.String getNullIfMissing(java.lang.String prefix, java.lang.String key)
          Returns the string corresponding to the specified string in the bundle file corresponding to the name prefix.
static void setLanguage(java.util.Locale l)
          Given a locale, start using the code short phrases for that lanuage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_FILE_PREFIX

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

MENU_FILE_PREFIX

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

PAPER_FILE_PREFIX

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

locale

protected static java.util.Locale locale

bundles

protected static java.util.HashMap bundles
Constructor Detail

I18N

public I18N()
Method Detail

setLanguage

public static void setLanguage(java.util.Locale l)
Given a locale, start using the code short phrases for that lanuage. Normally, you won't have to call this method. It gets called at startup and sets the locale to the default one.

Parameters:
l - the new locale

get

public static java.lang.String get(java.lang.String key)
Returns the string corresponding to the specified string. Returns key if key is either null or the empty string. Reports an error if key does not exist.

Parameters:
key - the lookup key
Returns:
the string corresponding to the specified lookup key or null if there isn't one; if key is the empty string, return it

get

public static java.lang.String get(java.lang.String prefix,
                                   java.lang.String key)
Returns the string corresponding to the specified string in the bundle file corresponding to the name prefix. Returns key if key is either null or the empty string. Reports an error if key does not exist.

Parameters:
prefix - the bundle file name prefix
key - the lookup key
Returns:
the string corresponding to the specified lookup key or null if there isn't one; if key is the empty string, return it

getNullIfMissing

public static java.lang.String getNullIfMissing(java.lang.String key)
Returns the string corresponding to the specified string. Returns key if key is either null or the empty string. Reports null if key does not exist.

Parameters:
key - the lookup key
Returns:
the string corresponding to the specified lookup key or null if there isn't one; if key is the empty string, return it

getNullIfMissing

public static java.lang.String getNullIfMissing(java.lang.String prefix,
                                                java.lang.String key)
Returns the string corresponding to the specified string in the bundle file corresponding to the name prefix. Returns key if key is either null or the empty string. Reports null if key does not exist.

Parameters:
prefix - the bundle file name prefix
key - the lookup key
Returns:
the string corresponding to the specified lookup key or null if there isn't one; if key is the empty string, return it

getBundle

protected static java.util.ResourceBundle getBundle(java.lang.String prefix)