|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--au.edu.swin.synergy.kernel.BPlugin | +--au.edu.swin.synergy.plugin.dialect.BDialect
The dialect class provides a common location for loading language resources from specific or global resources bundles.
This primarily consists of static methods which can be accessed without the need for command events however it will also add a language preferences panel to the Preferences plugin which will allow the user to change the current language to another.
When this happens, an dialect change event will be broadcast to all plugins on the client and it is up to them to update their users interfaces by requesting the required language resources from this plugin.
Field Summary | |
static String |
kGlobalTextFileName
This is the default name the global property files will have |
static String |
kPreferencesFile
The path of the preferences file |
protected static String |
kResourceExtension
This is the file name extension for language resource files |
static String |
kSavedLocale
The key in the preferences file for the locale |
static String |
kScreenTextFileName
This is the default name the property files should have |
Fields inherited from class au.edu.swin.synergy.kernel.BPlugin |
kernel |
Constructor Summary | |
BDialect()
|
Method Summary | |
protected void |
doDialectChange()
This will be called when the user changes the current dialect. |
protected static void |
doLoad()
This will load up the last used locale so that we can start up with the last locale used next time. |
protected void |
doSave()
This will write the current locale to a file so that we can start up with the last locale used next time. |
static String |
formatText(String formatMe,
Object[] arguments)
When dealing with compound messages, you need to specify the location and type of the arguments in the compound message in the following form: eg. At {2,time,short} on {2,date,long}, we detected {1,number,integer} spaceships on the planet {0}. |
BStringList |
getDependancies()
Return a list of plugin dependancies |
static String |
getString(Object object,
String key)
This will find the screentext<>.properties file in the same directory as the class is defined of the object passed in. |
static String |
getString(Object object,
String key,
Locale locale)
This will find the screentext<>.properties file in the same directory as the class is defined of the object passed in. |
static String |
getString(Object object,
String key,
Object[] args)
This will find the screentext<>.properties file in the same directory as the class is defined of the object passed in. |
static String |
getString(String key)
This version of getString will search the global text language resource file for the text mapping to the given key. |
static String |
getString(String key,
Locale locale)
This version of getString will search the global text language resource file for the text mapping to the given key. |
String |
getString(String key,
Object[] args)
This version of getString will search the global text language resource file for the text mapping to the given key. |
void |
onBCommandEvent(Object source,
BCommandEvent event)
When events are dispatched by the kernel, they are received here. |
void |
setup(BStringList params)
Called by the kernel when the plugin is first loaded |
Methods inherited from class au.edu.swin.synergy.kernel.BPlugin |
dispatchEvent,
dispatchEventAndWait,
dispatchEventServer,
dispatchEventServerAndWait,
dispatchEventTo,
dispatchEventToAndWait,
getKernel,
setKernel,
setup,
unload |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final String kScreenTextFileName
protected static final String kResourceExtension
public static final String kGlobalTextFileName
public static final String kPreferencesFile
public static final String kSavedLocale
Constructor Detail |
public BDialect()
Method Detail |
public String getString(String key, Object[] args)
In addition, it will take the arguments array and format the text before returning it initially.
Because the global properties file is defined by the BDialect plugin you don't need to specify any file or location, it already knows.
key
- The key to be mapped to a value in the resource filepublic static String getString(String key)
Because the global properties file is defined by the BDialect plugin you don't need to specify any file or location, it already knows.
key
- The key to be mapped to a value in the resource filepublic static String getString(String key, Locale locale)
Because the global properties file is defined by the BDialect plugin you don't need to specify any file or location, it already knows.
key
- The key to be mapped to a value in the resource filelocale
- The locale to get the text forpublic static String getString(Object object, String key, Object[] args)
For example, if the plugin au.edu.swin.synergy.plugin.mod13.BWindowManager wants to load a resource, it will pass in an instance of the window manager, or anything else declared in the same package.
The package is taken from it, converted to a path and the basename is appended to the end of the package. It will therefore try and locate it in the directory: ./au/edu/swin/synergy/plugin/mod13/screentext.properties or a more specific version for specific locales.
object
- The object who's package indicates the location of the resource filekey
- The key to be mapped to a value.public static String getString(Object object, String key)
For example, if the plugin au.edu.swin.synergy.plugin.mod13.BWindowManager wants to load a resource, it will pass in an instance of the window manager, or anything else declared in the same package.
The package is taken from it, converted to a path and the basename is appended to the end of the package. It will therefore try and locate it in the directory: ./au/edu/swin/synergy/plugin/mod13/screentext.properties or a more specific version for specific locales.
object
- The object who's package indicates the location of the resource filekey
- The key to be mapped to a value.public static String getString(Object object, String key, Locale locale)
For example, if the plugin au.edu.swin.synergy.plugin.mod13.BWindowManager wants to load a resource, it will pass in an instance of the window manager, or anything else declared in the same package.
The package is taken from it, converted to a path and the basename is appended to the end of the package. It will therefore try and locate it in the directory: ./au/edu/swin/synergy/plugin/mod13/screentext.properties or a more specific version for specific locales.
object
- The object who's package indicates the location of the resource filekey
- The key to be mapped to a value.locale
- The locale to get the text forprotected void doDialectChange()
public static String formatText(String formatMe, Object[] arguments)
eg.
At {2,time,short} on {2,date,long}, we detected {1,number,integer} spaceships on the planet {0}.
Where {2, time, short} indicates the third argument in the argument array, it is a time and short is the short date format
{2, date, long} indicates the third argument again, date says it's in date format, and long says long date format
{1, number, integer} Indicates second argument in array, it's a number and should be an integer (as opposed to float)
{0} The first String in the argument array
formatMe
- The compound string to formatarguments
- The arguments for the compound statementpublic void onBCommandEvent(Object source, BCommandEvent event)
protected void doSave()
protected static void doLoad()
public void setup(BStringList params)
public BStringList getDependancies()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |