Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.caff.gimmix
Class I18n

    java.lang.Object
      de.caff.gimmix.I18n

    public class I18n

extends java.lang.Object

Application specific support for internationalisation. This allows support for several resource classes for one application but has the big disadvantage that separate resource bundles may not define the same keys. Beware of that! You can switch DEBUG on to see if this happens.

This design should be overworked when possible.

To allow for enhancements the previous static design is now switched to something more object-oriented. This allows to take advantages of the new possibilities introduced with Java 1.2.

Field Summary
`protected java.util.List<java.lang.String>` | `appResourceBases` The resource bases.
`(package private) static boolean` | `DEBUG` Switch on to see whether there are key clashes.
`protected java.util.Locale` | `defaultLocale` The default locale.
`protected java.util.List<java.lang.ref.WeakReference<Localizable>>` | `localizables` Collection of known localizables, which have to be informed of localization changes.
`protected java.util.Map<java.util.Locale,ResourceBundleCollection>` | `resourceBundles` The resource bundles.

Constructor Summary
`I18n()`

Method Summary
`protected void` | `_addAppResourceBase(java.lang.String base)` Add an application specific resource class base name.
`protected void` | `_addLocalizationChangeListener(Localizable localizable)` Add a listener for localization changes.
`protected void` | `_fireLocaleChanged(java.util.Locale locale)` Tell all registered localizables of localization changes.
`protected java.util.ResourceBundle` | `_getBundle(java.util.Locale l)` Get a ResourceBundle for a locale.
`protected java.util.Locale` | `_getDefaultLocale()` Get the locale to be used as a default for the application.
`protected void` | `_removeLocalizationChangeListener(Localizable localizable)` Remove a listener for localization changes.
`protected void` | `_setDefaultLocale(java.util.Locale l)` Set the locale to be used as a default for the application.
`static void` | `addAppResourceBase(java.lang.String base)` Add an application specific resource class base name.
`static void` | `addLocalizationChangeListener(Localizable localizable)` Add a listener for localization changes.
`static java.lang.String` | `format(java.util.Locale l, java.lang.String tag, java.lang.Object... args)` Compile a String with a format.
`static java.lang.String` | `format(java.lang.String tag, java.lang.Object... args)` Compile a String with a format using the default locale.
`static java.util.Locale` | `getDefaultLocale()` Get the locale to be used as a default for the application.
`static java.lang.String` | `getString(java.lang.String tag)` Get a string for the default locale.
`static java.lang.String` | `getString(java.lang.String tag, java.util.Locale l)` Get a String specified by a Locale.
`static void` | `removeLocalizationChangeListener(Localizable localizable)` Remove a listener for localization changes.
`static void` | `setDefaultLocale(java.util.Locale l)` Set the locale to be used as a default for the application.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEBUG

    static boolean DEBUG

  Switch on to see whether there are key clashes.

### resourceBundles

    protected java.util.Map<java.util.Locale,ResourceBundleCollection> resourceBundles

  The resource bundles.

### appResourceBases

    protected java.util.List<java.lang.String> appResourceBases

  The resource bases.

### defaultLocale

    protected java.util.Locale defaultLocale

  The default locale.

### localizables

    protected java.util.List<java.lang.ref.WeakReference<Localizable>> localizables

  Collection of known localizables, which have to be informed of localization changes.

  The localizables are only weakly referenced here.

Constructor Detail

### I18n

    public I18n()

Method Detail

### addAppResourceBase

    public static void addAppResourceBase(java.lang.String base)

  Add an application specific resource class base name. This should be called by any application/applet before any other i18n specific code is used.

  Parameters:
    `base` - base class name for resources
  See Also:
    `ResourceBundle`

### _addAppResourceBase

    protected void _addAppResourceBase(java.lang.String base)

  Add an application specific resource class base name. This should be called by any application/applet before any other i18n specific code is used.

  Parameters:
    `base` - base class name for resources
  See Also:
    `ResourceBundle`

### setDefaultLocale

    public static void setDefaultLocale(java.util.Locale l)

  Set the locale to be used as a default for the application.

  Parameters:
    `l` - locale to be used as default

### _setDefaultLocale

    protected void _setDefaultLocale(java.util.Locale l)

  Set the locale to be used as a default for the application.

  Parameters:
    `l` - locale to be used as default

### getDefaultLocale

    public static java.util.Locale getDefaultLocale()

  Get the locale to be used as a default for the application.

  Returns:
    locale to be used as default

### _getDefaultLocale

    protected java.util.Locale _getDefaultLocale()

  Get the locale to be used as a default for the application.

  Returns:
    locale to be used as default

### _getBundle

    protected java.util.ResourceBundle _getBundle(java.util.Locale l)
                                           throws java.util.MissingResourceException

  Get a ResourceBundle for a locale.

  Throws:
    `java.util.MissingResourceException` - when no appResourceBase is set
  Parameters:
    `l` - locale
  Returns:
    ResourceBundle for that Locale

### getString

    public static java.lang.String getString(java.lang.String tag)
                                      throws java.util.MissingResourceException

  Get a string for the default locale.

  Throws:
    `java.util.MissingResourceException` - when no appResourceBase is set
  Parameters:
    `tag` - resource tag
  Returns:
    localized string

### getString

    public static java.lang.String getString(java.lang.String tag,
                                             java.util.Locale l)
                                      throws java.util.MissingResourceException

  Get a String specified by a Locale.

  Throws:
    `java.util.MissingResourceException` - when no appResourceBase is set
  Parameters:
    `tag` - resource tag
    `l` - Locale to be used
  Returns:
    localized String
  See Also:
    `ResourceBundle.getString(java.lang.String)`

### format

    public static java.lang.String format(java.lang.String tag,
                                          java.lang.Object... args)
                                   throws java.util.MissingResourceException

  Compile a String with a format using the default locale.

  Throws:
    `java.util.MissingResourceException` - when no appResourceBase is set
  Parameters:
    `tag` - resource tag of format
    `args` - arguments
  Returns:
    localized String
  See Also:
    `Utility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)`

### format

    public static java.lang.String format(java.util.Locale l,
                                          java.lang.String tag,
                                          java.lang.Object... args)
                                   throws java.util.MissingResourceException

  Compile a String with a format.

  Throws:
    `java.util.MissingResourceException` - when no appResourceBase is set
  Parameters:
    `l` - locale
    `tag` - resource tag of format
    `args` - arguments
  Returns:
    localized String
  See Also:
    `Utility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)`

### addLocalizationChangeListener

    public static void addLocalizationChangeListener(Localizable localizable)

  Add a listener for localization changes.

  Parameters:
    `localizable` - listener for changes

### _addLocalizationChangeListener

    protected void _addLocalizationChangeListener(Localizable localizable)

  Add a listener for localization changes.

  Parameters:
    `localizable` - listener for changes

### removeLocalizationChangeListener

    public static void removeLocalizationChangeListener(Localizable localizable)

  Remove a listener for localization changes.

  Parameters:
    `localizable` - listener to be removed

### _removeLocalizationChangeListener

    protected void _removeLocalizationChangeListener(Localizable localizable)

  Remove a listener for localization changes.

  Parameters:
    `localizable` - listener to be removed

### _fireLocaleChanged

    protected void _fireLocaleChanged(java.util.Locale locale)

  Tell all registered localizables of localization changes.

  Parameters:
    `locale` - new locale

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD