public class I18nManager extends Object
I18n
objects and LocaleChangeListener
objects.
The locale of all managed I18n
objects can be changed by
invoking setDefaultLocale(Locale)
.
Modifier and Type | Method and Description |
---|---|
void |
add(I18n i18n)
Adds
i18n to the list of managed I18n
objects. |
void |
addLocaleChangeListener(LocaleChangeListener listener)
Adds a listener that is notified when the default locale has been
changed.
|
void |
addWeakLocaleChangeListener(LocaleChangeListener listener)
Adds a listener that is notified when the default locale has been changed
using a
WeakReference . |
protected void |
fireLocaleChangedEvent(Locale newLocale)
Notifies listeners of a locale change.
|
static I18nManager |
getInstance()
Returns the global
I18Manger singleton. |
void |
remove(I18n i18n)
Removes
i18n from the list of managed I18n
objects. |
void |
removeLocaleChangeListener(LocaleChangeListener listener)
Removes
listener from the list of objects that are
notified when the locale has changed. |
void |
setDefaultLocale(Locale locale)
Sets the locale for all I18n instances that were instantiated through the
factory.
|
public static I18nManager getInstance()
I18Manger
singleton.I18Manger
instancepublic void add(I18n i18n)
i18n
to the list of managed I18n
objects.i18n
- the I18n
instancesetDefaultLocale(Locale)
,
remove(I18n)
public void setDefaultLocale(Locale locale)
Use this method to globally change the locale for all I18n based translations.
NOTE: This only works if the objects that display messages do not cache translated messages.
locale
- the new default localeI18n.setLocale(Locale)
public void addLocaleChangeListener(LocaleChangeListener listener)
listener
- the listenersetDefaultLocale(Locale)
public void addWeakLocaleChangeListener(LocaleChangeListener listener)
WeakReference
. The listener is removed when it has been
cleaned up by the garbage collection.
This is useful for temporary objects that may have an indeterminate lifetime such as dialogs.
listener
- the listenersetDefaultLocale(Locale)
public void remove(I18n i18n)
i18n
from the list of managed I18n
objects.i18n
- the I18n
instanceadd(I18n)
public void removeLocaleChangeListener(LocaleChangeListener listener)
listener
from the list of objects that are
notified when the locale has changed.listener
- the listenerprotected void fireLocaleChangedEvent(Locale newLocale)
newLocale
- new localeCopyright © 2014. All rights reserved.