public abstract class I18n
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTION_SUFFIX
General suffix for action specific resources.
|
(package private) static boolean |
DEBUG
Switch on to see whether there are key clashes.
|
static java.lang.String |
SUFFIX_ACCELERATOR
The i18n tag suffix added for an accelarator.
|
static java.lang.String |
SUFFIX_DESCRIPTION
The i18n tag suffix added for a description.
|
static java.lang.String |
SUFFIX_DISABLED_ICON
The i18n tag suffix added for the path of an icon used for the disabled state.
|
static java.lang.String |
SUFFIX_ICON
The i18n tag suffix added for an icon path.
|
static java.lang.String |
SUFFIX_INACTIVE_ICON
The i18n tag suffix added for the path of an icon used for the inactive state.
|
static java.lang.String |
SUFFIX_MNEMONIC
The i18n tag suffix added for a mnemonic.
|
static java.lang.String |
SUFFIX_TEXT
The i18n tag suffix added for a label/button text/menu text.
|
static java.lang.String |
SUFFIX_TOOLTIP
The i18n tag suffix added for a tooltip.
|
Constructor and Description |
---|
I18n() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
_addAppResourceBase(java.lang.String base,
boolean prepend)
Add an application specific resource class base name.
|
protected abstract void |
_addLocalizationChangeListener(Localizable localizable)
Add a listener for localization changes.
|
protected abstract void |
_dumpResources(java.io.PrintStream out,
java.util.Locale locale)
Dump the complete currently known i18n resources for a given locale.
|
protected abstract void |
_fireLocaleChanged(java.util.Locale locale)
Tell all registered localizables of localization changes.
|
protected abstract java.util.ResourceBundle |
_getBundle(java.util.Locale l)
Get a ResourceBundle for a locale.
|
protected abstract java.util.Locale |
_getDefaultLocale()
Get the locale to be used as a default for the application.
|
protected abstract java.util.ResourceBundle |
_getFallbackBundle()
Get the fallback resource bundle.
|
protected abstract void |
_removeLocalizationChangeListener(Localizable localizable)
Remove a listener for localization changes.
|
protected abstract 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 |
addAppResourceBase(java.lang.String base,
boolean prepend)
Add an application specific resource class base name.
|
static void |
addLocalizationChangeListener(Localizable localizable)
Add a listener for localization changes.
|
static void |
dump(java.io.PrintStream out,
java.util.Locale locale)
Dump the complete currently known i18n resources for a given locale.
|
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 |
getFormattedString(java.util.Locale l,
java.lang.String tag,
java.lang.Object... args)
Compile a String with a format.
|
static java.lang.String |
getFormattedString(java.lang.String tag,
java.lang.Object... args)
Compile a String with a format using the default locale.
|
static javax.swing.Icon |
getIcon(java.lang.String tag)
Get an icon from a tag defining its location, using the default locale.
|
static javax.swing.Icon |
getIcon(java.lang.String tag,
java.util.Locale locale)
Get an icon from a tag defining its location.
|
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.
|
static final boolean DEBUG
public static final java.lang.String ACTION_SUFFIX
public static final java.lang.String SUFFIX_TEXT
public static final java.lang.String SUFFIX_TOOLTIP
public static final java.lang.String SUFFIX_DESCRIPTION
public static final java.lang.String SUFFIX_ACCELERATOR
public static final java.lang.String SUFFIX_MNEMONIC
public static final java.lang.String SUFFIX_ICON
public static final java.lang.String SUFFIX_DISABLED_ICON
public static final java.lang.String SUFFIX_INACTIVE_ICON
public static void addAppResourceBase(@NotNull java.lang.String base)
base
- base class name for resourcesResourceBundle
public static void addAppResourceBase(@NotNull java.lang.String base, boolean prepend)
base
- base class name for resourcesprepend
- prepend this resource base?ResourceBundle
protected abstract void _addAppResourceBase(@NotNull java.lang.String base, boolean prepend)
base
- base class name for resourcesprepend
- prepend this resource base?ResourceBundle
public static void setDefaultLocale(java.util.Locale l)
l
- locale to be used as defaultprotected abstract void _setDefaultLocale(@Nullable java.util.Locale l)
l
- locale to be used as default (system default if null
)@NotNull public static java.util.Locale getDefaultLocale()
@NotNull protected abstract java.util.Locale _getDefaultLocale()
protected abstract java.util.ResourceBundle _getFallbackBundle()
@NotNull protected abstract java.util.ResourceBundle _getBundle(@Nullable java.util.Locale l) throws java.util.MissingResourceException
l
- localejava.util.MissingResourceException
- when no appResourceBase is setprotected abstract void _dumpResources(@NotNull java.io.PrintStream out, @Nullable java.util.Locale locale)
out
- print stream where to dump tolocale
- locale for which to dump the resourcespublic static void dump(@NotNull java.io.PrintStream out, @Nullable java.util.Locale locale)
out
- print stream where to dump tolocale
- locale for which to dump the resources@NotNull public static java.lang.String getString(@NotNull java.lang.String tag) throws java.util.MissingResourceException
tag
- resource tagjava.util.MissingResourceException
- when no appResourceBase is set@NotNull public static java.lang.String getString(@NotNull java.lang.String tag, @Nullable java.util.Locale l) throws java.util.MissingResourceException
tag
- resource tagl
- Locale to be usedjava.util.MissingResourceException
- when no appResourceBase is setResourceBundle.getString(java.lang.String)
@NotNull public static java.lang.String format(@NotNull java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
tag
- resource tag of formatargs
- argumentsjava.util.MissingResourceException
- when no appResourceBase is setUtility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
@NotNull public static java.lang.String format(@Nullable java.util.Locale l, @NotNull java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
l
- localetag
- resource tag of formatargs
- argumentsjava.util.MissingResourceException
- when no appResourceBase is setUtility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
@NotNull public static java.lang.String getFormattedString(@NotNull java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
tag
- resource tag of formatargs
- argumentsjava.util.MissingResourceException
- when no appResourceBase is setUtility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
@NotNull public static java.lang.String getFormattedString(@Nullable java.util.Locale l, @NotNull java.lang.String tag, java.lang.Object... args) throws java.util.MissingResourceException
l
- localetag
- resource tag of formatargs
- argumentsjava.util.MissingResourceException
- when no appResourceBase is setUtility.compileString(java.lang.String, java.lang.Object[], java.util.ResourceBundle)
public static void addLocalizationChangeListener(@NotNull Localizable localizable)
localizable
- listener for changesprotected abstract void _addLocalizationChangeListener(@NotNull Localizable localizable)
localizable
- listener for changespublic static void removeLocalizationChangeListener(@NotNull Localizable localizable)
localizable
- listener to be removedprotected abstract void _removeLocalizationChangeListener(@NotNull Localizable localizable)
localizable
- listener to be removedprotected abstract void _fireLocaleChanged(java.util.Locale locale)
locale
- new locale@Nullable public static javax.swing.Icon getIcon(@NotNull java.lang.String tag)
tag
- i18n tagnull
if there is no icon defined for the tag
or it cannot be loaded