jsky.util
Class I18N

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

public class I18N
extends java.lang.Object

Simple utility class for accessing property file resource bundles for internationalization.

This class assumes one property file per package, as needed. The convention used here is to store the property files in a subdirectory of the package named i18n. The base name is gui, so the default property file is i18n/gui.properties. The German version would then be i18n/gui_de.properties and the French version would be i18n/gui_fr.properties. The property files need to be installed in the same relative directory in the classes dir or jar file before use.

Version:
$Revision: 1.1 $
Author:
Allan Brighton (modified original version by Guillaume Helle)

Method Summary
static I18N getInstance(java.lang.Class c)
          Return an instance of I18N, initialized to use i18n/gui_.properties, relative to the package directory for the given class.
 java.lang.String getString(java.lang.String key)
          Return the string for the specified key in the current locale.
 java.lang.String getString(java.lang.String key, java.lang.Object p1)
          Return the string for the specified key in the current locale after substituting the given parameter using the MessageFormat class.
 java.lang.String getString(java.lang.String key, java.lang.Object[] params)
          Return the string for the specified key in the current locale after substituting the given parameters using the MessageFormat class.
 java.lang.String getString(java.lang.String key, java.lang.Object p1, java.lang.Object p2)
          Return the string for the specified key in the current locale after substituting the given parameters (p1 and p2) using the MessageFormat class.
 java.lang.String getString(java.lang.String key, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          Return the string for the specified key in the current locale after substituting the given parameters (p1 and p2) using the MessageFormat class.
static void main(java.lang.String[] args)
          test main
 void setLocale(java.util.Locale locale)
          Set the current locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static I18N getInstance(java.lang.Class c)
Return an instance of I18N, initialized to use i18n/gui_.properties, relative to the package directory for the given class.


setLocale

public void setLocale(java.util.Locale locale)
Set the current locale.


getString

public java.lang.String getString(java.lang.String key)
Return the string for the specified key in the current locale.


getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object[] params)
Return the string for the specified key in the current locale after substituting the given parameters using the MessageFormat class.

See Also:
MessageFormat

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object p1)
Return the string for the specified key in the current locale after substituting the given parameter using the MessageFormat class.

See Also:
MessageFormat

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object p1,
                                  java.lang.Object p2)
Return the string for the specified key in the current locale after substituting the given parameters (p1 and p2) using the MessageFormat class.

See Also:
MessageFormat

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object p1,
                                  java.lang.Object p2,
                                  java.lang.Object p3)
Return the string for the specified key in the current locale after substituting the given parameters (p1 and p2) using the MessageFormat class.

See Also:
MessageFormat

main

public static void main(java.lang.String[] args)
test main