public class I18nApplicationLocale
extends java.util.Observable
For application use, for example a UI:
For change application locale,class UI extends JFrame implements Observer{ private JButton button; private JLabel label; public UI(){ //initialize component //register to I18nApplicationLocale I18nApplicationLocale.getInstance().addObserver(this); } // Overrides Observer public void update(Observable o, Object argument) { setLocaleMessage(); } public void setLocaleMessage(){ button.setText(I18n.getMessage(DefaultBundleMessageType.UI,"2000")); label.setText(I18n.getMessage(DefaultBundleMessageType.UI,"2001")); } }
I18nApplicationLocale.getInstance().changeLocale(locale)
Modifier | Constructor and Description |
---|---|
protected |
I18nApplicationLocale() |
Modifier and Type | Method and Description |
---|---|
void |
changeCurrentLocale(java.util.Locale locale)
change a new locale, if it change successfully, it will notify all registered observer.
|
java.util.Locale |
getCurrentLocale()
get application current locale
|
static I18nApplicationLocale |
getInstance()
get a singleton instance
|
public static I18nApplicationLocale getInstance()
public java.util.Locale getCurrentLocale()
public void changeCurrentLocale(java.util.Locale locale)
locale
- Locale new locale wanted to change