net.sf.jomic.tools
Class LocaleTools

java.lang.Object
  extended by net.sf.jomic.tools.LocaleTools
All Implemented Interfaces:
PropertyChangeListener, EventListener

public final class LocaleTools
extends Object
implements PropertyChangeListener

Tools for localization.

Author:
Thomas Aglassinger

Field Summary
static String MENU_EDIT
           
static String MENU_FILE
           
static String MENU_GO
           
static String MENU_HELP
           
static String MENU_VIEW
           
 
Method Summary
 String asByteText(long amount)
           
 JButton createButton(String buttonKey)
           
 JButton createCancelButton()
           
 JMenu createMenu(String menuKey)
           
 JMenuItem createMenuItem(String subMenu, String itemKey)
           
 JRadioButtonMenuItem createRadioButtonMenuItem(String subMenu, ButtonGroup group, String itemKey)
           
 ResourceBundle getBundle()
          Get ResourceBundle for localization.
 String getCancelText()
          Get text to be used for "Cancel" buttons.
 Locale getLocale()
           
 Locale getLocaleForLanguageCountryVariant(String languageCountryVariant)
          Get locale specified by languageCountryVariant.
 String getMenuItemLabel(String subMenu, String itemKey)
           
 String getMenuLabel(String menuKey)
           
 String getMessage(String key)
          Get localized message (without options).
 String getMessage(String key, Object option)
          Get localized message with one option referred to as {0}.
 String getMessage(String key, Object[] options)
          Get localized message with several options referred to as {0}, {1}, and so on.
 String getOkText()
          Get text to be used for "OK" buttons.
static LocaleTools instance()
           
 String[] parseLanguageCountryVariant(String languageCountryVariant)
          Parse a string of the form "language_country_variant" (with any of the elements being optional), and return an array containing the elements.
 void propertyChange(PropertyChangeEvent event)
           
 void setLocale(Locale newLocale)
          Set Locale to use with Jomic.
 void setLocale(String displayName)
          Set Locale to use with Jomic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_EDIT

public static final String MENU_EDIT
See Also:
Constant Field Values

MENU_FILE

public static final String MENU_FILE
See Also:
Constant Field Values

MENU_GO

public static final String MENU_GO
See Also:
Constant Field Values

MENU_HELP

public static final String MENU_HELP
See Also:
Constant Field Values

MENU_VIEW

public static final String MENU_VIEW
See Also:
Constant Field Values
Method Detail

setLocale

public void setLocale(Locale newLocale)
Set Locale to use with Jomic.


setLocale

public void setLocale(String displayName)
Set Locale to use with Jomic.


getBundle

public ResourceBundle getBundle()
Get ResourceBundle for localization.


getCancelText

public String getCancelText()
Get text to be used for "Cancel" buttons.


getLocale

public Locale getLocale()

getLocaleForLanguageCountryVariant

public Locale getLocaleForLanguageCountryVariant(String languageCountryVariant)
Get locale specified by languageCountryVariant.

Parameters:
languageCountryVariant - text of the form "language_region_variant", for example "en" or "de_AT"

getMenuItemLabel

public String getMenuItemLabel(String subMenu,
                               String itemKey)

getMenuLabel

public String getMenuLabel(String menuKey)

getMessage

public String getMessage(String key)
Get localized message (without options).


getMessage

public String getMessage(String key,
                         Object[] options)
Get localized message with several options referred to as {0}, {1}, and so on.


getMessage

public String getMessage(String key,
                         Object option)
Get localized message with one option referred to as {0}.


getOkText

public String getOkText()
Get text to be used for "OK" buttons.


instance

public static LocaleTools instance()

asByteText

public String asByteText(long amount)

createButton

public JButton createButton(String buttonKey)

createCancelButton

public JButton createCancelButton()

createMenu

public JMenu createMenu(String menuKey)

createMenuItem

public JMenuItem createMenuItem(String subMenu,
                                String itemKey)

createRadioButtonMenuItem

public JRadioButtonMenuItem createRadioButtonMenuItem(String subMenu,
                                                      ButtonGroup group,
                                                      String itemKey)

parseLanguageCountryVariant

public String[] parseLanguageCountryVariant(String languageCountryVariant)
Parse a string of the form "language_country_variant" (with any of the elements being optional), and return an array containing the elements. If no element has been specified, it will be empty ("").

Parameters:
languageCountryVariant - of the form "language_region_variant", for example "en" or "de_AT", or null to indicate the default Locale.

propertyChange

public void propertyChange(PropertyChangeEvent event)
Specified by:
propertyChange in interface PropertyChangeListener