|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.caff.gimmix.I18n
public class I18n
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 |
---|
static boolean DEBUG
protected java.util.Map<java.util.Locale,ResourceBundleCollection> resourceBundles
protected java.util.List<java.lang.String> appResourceBases
protected java.util.Locale defaultLocale
protected java.util.List<java.lang.ref.WeakReference<Localizable>> localizables
The localizables are only weakly referenced here.
Constructor Detail |
---|
public I18n()
Method Detail |
---|
public static void addAppResourceBase(java.lang.String base)
base
- base class name for resourcesResourceBundle
protected void _addAppResourceBase(java.lang.String base)
base
- base class name for resourcesResourceBundle
public static void setDefaultLocale(java.util.Locale l)
l
- locale to be used as defaultprotected void _setDefaultLocale(java.util.Locale l)
l
- locale to be used as defaultpublic static java.util.Locale getDefaultLocale()
protected java.util.Locale _getDefaultLocale()
protected java.util.ResourceBundle _getBundle(java.util.Locale l) throws java.util.MissingResourceException
java.util.MissingResourceException
- when no appResourceBase is setl
- locale
public static java.lang.String getString(java.lang.String tag) throws java.util.MissingResourceException
java.util.MissingResourceException
- when no appResourceBase is settag
- resource tag
public static java.lang.String getString(java.lang.String tag, java.util.Locale l) throws java.util.MissingResourceException
java.util.MissingResourceException
- when no appResourceBase is settag
- resource tagl
- Locale to be used
ResourceBundle.getString(java.lang.String)
public static java.lang.String format(java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
java.util.MissingResourceException
- when no appResourceBase is settag
- resource tag of formatargs
- arguments
Utility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
public static java.lang.String format(java.util.Locale l, java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
java.util.MissingResourceException
- when no appResourceBase is setl
- localetag
- resource tag of formatargs
- arguments
Utility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
public static void addLocalizationChangeListener(Localizable localizable)
localizable
- listener for changesprotected void _addLocalizationChangeListener(Localizable localizable)
localizable
- listener for changespublic static void removeLocalizationChangeListener(Localizable localizable)
localizable
- listener to be removedprotected void _removeLocalizationChangeListener(Localizable localizable)
localizable
- listener to be removedprotected void _fireLocaleChanged(java.util.Locale locale)
locale
- new locale
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |