|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uk.ac.essex.common.lang.LanguageServiceImpl
public class LanguageServiceImpl
A useful implmentation of LanguageService that loads its configuration from two XML files called
'availableLocales.xml' and 'availableResources.xml'. These are searched for on the classpath and once
loaded this class attempts to load each of the available resource base names for all the given locales.
Date: 15-Jul-2002
Field Summary | |
---|---|
protected java.util.prefs.Preferences |
preferences
|
Fields inherited from interface uk.ac.essex.common.lang.LanguageService |
---|
DEFAULT_LANGUAGE |
Constructor Summary | |
---|---|
LanguageServiceImpl()
|
Method Summary | |
---|---|
void |
add(ResourceConfigXML resourceConfig)
|
void |
addResourceConfig(java.lang.String fileName)
Add a resource config that gives the application localization resources to configure for this service |
void |
destroy()
Destroy the service |
java.util.Locale |
getCurrentLocale()
|
void |
initialise()
Initialise the service, here we load the config file for the commons package |
static void |
main(java.lang.String[] argStrings)
|
void |
registerInternationlisedAction(javax.swing.Action action,
java.lang.String nameKey)
Just calls registerInternationlisedAction(javax.swing.Action, java.lang.String, java.lang.String,
java.lang.String) passing in null for long and short descriptions |
void |
registerInternationlisedAction(javax.swing.Action action,
java.lang.String nameKey,
java.lang.String shortDescriptionKey,
java.lang.String longDescriptionKey)
Registers and sets the text of the action using the LanguageService.DEFAULT_LANGUAGE |
void |
registerInternationlisedComponent(javax.swing.JButton button,
java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE |
void |
registerInternationlisedComponent(javax.swing.JCheckBox box,
java.lang.String key)
Registers and sets text of checkbox |
void |
registerInternationlisedComponent(javax.swing.JLabel label,
java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE |
void |
registerInternationlisedComponent(javax.swing.JMenu menu,
java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE |
void |
registerInternationlisedComponent(javax.swing.JRadioButton radioButton,
java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE |
void |
registerInternationlisedComponent(javax.swing.border.TitledBorder border,
java.lang.String key)
|
void |
setCurrentLocale(java.util.Locale locale)
|
java.lang.String |
translate(java.util.Locale locale,
java.lang.String key)
|
java.lang.String |
translate(java.lang.String key)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.prefs.Preferences preferences
Constructor Detail |
---|
public LanguageServiceImpl()
Method Detail |
---|
public void registerInternationlisedAction(javax.swing.Action action, java.lang.String nameKey)
registerInternationlisedAction(javax.swing.Action, java.lang.String, java.lang.String,
java.lang.String)
passing in null for long and short descriptions
action
- nameKey
- public void registerInternationlisedAction(javax.swing.Action action, java.lang.String nameKey, java.lang.String shortDescriptionKey, java.lang.String longDescriptionKey)
LanguageService.DEFAULT_LANGUAGE
action
- nameKey
- shortDescriptionKey
- - Can be nulllongDescriptionKey
- - Can be nullpublic void registerInternationlisedComponent(javax.swing.JCheckBox box, java.lang.String key)
box
- key
- public void registerInternationlisedComponent(javax.swing.JButton button, java.lang.String key)
LanguageService.DEFAULT_LANGUAGE
button
- key
- public void registerInternationlisedComponent(javax.swing.JLabel label, java.lang.String key)
LanguageService.DEFAULT_LANGUAGE
label
- key
- public void registerInternationlisedComponent(javax.swing.border.TitledBorder border, java.lang.String key)
public void registerInternationlisedComponent(javax.swing.JMenu menu, java.lang.String key)
LanguageService.DEFAULT_LANGUAGE
menu
- key
- public void registerInternationlisedComponent(javax.swing.JRadioButton radioButton, java.lang.String key)
LanguageService.DEFAULT_LANGUAGE
radioButton
- key
- public void add(ResourceConfigXML resourceConfig)
add
in interface LanguageService
resourceConfig
- public void addResourceConfig(java.lang.String fileName) throws InitialisationException
addResourceConfig
in interface LanguageService
fileName
- - The file name, will be loaded from the classpath
InitialisationException
public java.lang.String translate(java.lang.String key)
translate
in interface LanguageService
key
-
public java.lang.String translate(java.util.Locale locale, java.lang.String key)
translate
in interface LanguageService
key
-
public void setCurrentLocale(java.util.Locale locale)
setCurrentLocale
in interface LanguageService
locale
- public java.util.Locale getCurrentLocale()
getCurrentLocale
in interface LanguageService
public void initialise() throws InitialisationException
initialise
in interface Service
InitialisationException
public void destroy() throws DestructionException, ShutdownCancelledException
destroy
in interface Service
DestructionException
ShutdownCancelledException
public static void main(java.lang.String[] argStrings)
argStrings
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |