net.sf.jomic.tools
Class LocaleTools

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

public final class LocaleTools
extends java.lang.Object
implements java.beans.PropertyChangeListener

Tools for localization.

Author:
Thomas Aglassinger

Field Summary
static java.lang.String MENU_EDIT
           
static java.lang.String MENU_FILE
           
static java.lang.String MENU_GO
           
static java.lang.String MENU_HELP
           
static java.lang.String MENU_VIEW
           
 
Method Summary
 java.lang.String asByteText(long amount)
           
 javax.swing.JButton createButton(java.lang.String buttonKey)
           
 javax.swing.JButton createCancelButton()
           
 javax.swing.JMenu createMenu(java.lang.String menuKey)
           
 javax.swing.JMenuItem createMenuItem(java.lang.String subMenu, java.lang.String itemKey)
           
 javax.swing.JRadioButtonMenuItem createRadioButtonMenuItem(java.lang.String subMenu, javax.swing.ButtonGroup group, java.lang.String itemKey)
           
 java.util.ResourceBundle getBundle()
          Get ResourceBundle for localization.
 java.lang.String getCancelText()
          Get text to be used for "Cancel" buttons.
 java.util.Locale getLocale()
           
 java.util.Locale getLocaleForLanguageCountryVariant(java.lang.String languageCountryVariant)
          Get locale specified by languageCountryVariant.
 java.lang.String getMenuItemLabel(java.lang.String subMenu, java.lang.String itemKey)
           
 java.lang.String getMenuLabel(java.lang.String menuKey)
           
 java.lang.String getMessage(java.lang.String key)
          Get localized message (without options).
 java.lang.String getMessage(java.lang.String key, java.lang.Object option)
          Get localized message with one option referred to as {0}.
 java.lang.String getMessage(java.lang.String key, java.lang.Object[] options)
          Get localized message with several options referred to as {0}, {1}, and so on.
 java.lang.String getOkText()
          Get text to be used for "OK" buttons.
static LocaleTools instance()
           
 java.lang.String[] parseLanguageCountryVariant(java.lang.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(java.beans.PropertyChangeEvent event)
           
 void setLocale(java.util.Locale newLocale)
          Set Locale to use with Jomic.
 void setLocale(java.lang.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 java.lang.String MENU_EDIT
See Also:
Constant Field Values

MENU_FILE

public static final java.lang.String MENU_FILE
See Also:
Constant Field Values

MENU_GO

public static final java.lang.String MENU_GO
See Also:
Constant Field Values

MENU_HELP

public static final java.lang.String MENU_HELP
See Also:
Constant Field Values

MENU_VIEW

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

setLocale

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


setLocale

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


getBundle

public java.util.ResourceBundle getBundle()
Get ResourceBundle for localization.


getCancelText

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


getLocale

public java.util.Locale getLocale()

getLocaleForLanguageCountryVariant

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

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

getMenuItemLabel

public java.lang.String getMenuItemLabel(java.lang.String subMenu,
                                         java.lang.String itemKey)

getMenuLabel

public java.lang.String getMenuLabel(java.lang.String menuKey)

getMessage

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


getMessage

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


getMessage

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


getOkText

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


instance

public static LocaleTools instance()

asByteText

public java.lang.String asByteText(long amount)

createButton

public javax.swing.JButton createButton(java.lang.String buttonKey)

createCancelButton

public javax.swing.JButton createCancelButton()

createMenu

public javax.swing.JMenu createMenu(java.lang.String menuKey)

createMenuItem

public javax.swing.JMenuItem createMenuItem(java.lang.String subMenu,
                                            java.lang.String itemKey)

createRadioButtonMenuItem

public javax.swing.JRadioButtonMenuItem createRadioButtonMenuItem(java.lang.String subMenu,
                                                                  javax.swing.ButtonGroup group,
                                                                  java.lang.String itemKey)

parseLanguageCountryVariant

public java.lang.String[] parseLanguageCountryVariant(java.lang.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(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener