|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--LocaleManager
Class for holding current locale information, and notify client application about locale changes. Used for dynamic (or static) locale updates and language translations during a program session.
For language dependent user interfaces, put translation files into the packages where reguired. The files are named as follows: Messages_xx_XX.properties where xx is the laguage identifier and XX is the country identifier, for instance
Messages_en_US.properties // american Messages_fr_FR.properties // french Messages_ch_CH.properties // chineeseand so on. These are ordinary properties files containing language translations, for instance (french):
Close = Fermer New = Nouveau Help = Aideand (american):
Close = Close New = New Help = Help
A locale aware GUI will use the locale manager like this:
JButton helpButton = new JButton(); : helpButton.setText (localeManager.getText ("Help"));If the latter is done inside a localeChanged callback, the GUI will update itself dynamically if locale is changed during a session.
Method Summary | |
void |
addLocaleListener(LocaleListener localeListener)
Add a locale listener. |
String |
getDate(Date date)
Return default localized text reprentation of the specified date. |
String |
getDate(Date date,
int style)
Return default localized text reprentation of the specified date. |
DateFormat |
getDateFormat(int style)
Get default date format for the current locale. |
String |
getDateTime(Date date)
Return default localized text representation of the specified date/time. |
String |
getDateTime(Date date,
int dateStyle,
int timeStyle)
Return default localized text representation of the specified date/time. |
DateFormat |
getDateTimeFormat(int dateStyle,
int timeStyle)
Get defaut date/time format for current locale. |
static LocaleManager |
getInstance()
Return the sole instance of this class. |
Locale |
getLocale()
Return current locale. |
String |
getText(String tag)
Return localized text for a specified tag. |
String |
getTime(Date date)
Return default localized text representation of the specified time. |
String |
getTime(Date date,
int style)
Return default localized text representation of the specified time. |
DateFormat |
getTimeFormat(int style)
Get default time format for the current locale. |
void |
removeLocaleListener(LocaleListener localeListener)
Remove a locale listener. |
void |
setDefaultLocale(String language,
String country)
Set the default locale. |
void |
setLocale(Locale locale)
Set current locale. |
void |
setLocale(String language,
String country)
Set the current locale, and notify listeners about the change. |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static LocaleManager getInstance()
public void setDefaultLocale(String language, String country)
language
- Language of default locale.country
- Country of default locale.public void setLocale(Locale locale)
locale
- New current locale.public Locale getLocale()
public void setLocale(String language, String country)
language
- Language of new locale.country
- Country of new locale.public String getText(String tag)
tag
- Tag of text to locate.
public void addLocaleListener(LocaleListener localeListener)
localeListener
- Listener to add.public void removeLocaleListener(LocaleListener localeListener)
localeListener
- Locale listener to remove.public DateFormat getDateFormat(int style)
style
- One of DateFormat.SHORT, MEDIUM or LONG.
public DateFormat getTimeFormat(int style)
style
- One of DateFormat.SHORT, MEDIUM or LONG.
public DateFormat getDateTimeFormat(int dateStyle, int timeStyle)
dateStyle
- One of DateFormat.SHORT, MEDIUM or LONG.timeStyle
- One of DateFormat.SHORT, MEDIUM or LONG.
public String getDate(Date date)
date
- Date to format.
public String getDate(Date date, int style)
date
- Date to format.style
- DateFormat.SHORT, MEDIUM or LONG
public String getTime(Date date, int style)
date
- Time to format.style
- DateFormat.SHORT, MEDIUM or LONG
public String getTime(Date date)
date
- Time to format.
public String getDateTime(Date date, int dateStyle, int timeStyle)
date
- Date/time to format.dateStyle
- One of DateFormat.SHORT, MEDIUM or LONG.timeStyle
- One of DateFormat.SHORT, MEDIUM or LONG.
public String getDateTime(Date date)
date
- Date/time to format.
|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |