misim.util
Class TxtBaseClass
java.lang.Object
|
+--misim.util.TxtBaseClass
- Direct Known Subclasses:
- Txt
- public abstract class TxtBaseClass
- extends java.lang.Object
The TxtBaseClass provides core functionality for the Txt class.
This includes methods for setting the language, and retrieving
messages ready to display.
The Internationalisation functions here are used as follows. The
TxtBaseClass provides a number of static methods for retrieving
messages based on their message Id and optionally replacement strings
that will be inserted into the message. Before these may be used
the abstract method setLanguage must be called to initialise the
language and static class variables.
The TxtBaseClass is extended by a machine generated file 'Txt.java'
which contains all of the messages and message identifier constants.
The Txt.java file is generated by the TxtParser class from a messages
file which lists messages on separate lines in plain text in the format:
MESSAGE_IDENTIFIER = some message
The Txt class implements the abstract method 'getMsg(messageID)' to
retrieve these messages.
Method Summary |
static java.lang.String |
doReplacements(java.lang.String message,
java.lang.String[] replacements)
|
static java.lang.String |
get(int message)
|
static java.lang.String |
get(int message,
int replacement)
|
static java.lang.String |
get(int message,
java.lang.String replacement)
|
static java.lang.String |
get(int message,
java.lang.String[] replacements)
|
static void |
parseGroup(SettingsGroup group,
java.lang.String[] identifiers,
java.lang.String[] messages)
|
static void |
prepare(java.lang.String aLanguage,
RobustReaderIF reader,
TxtBaseClass txtBase,
java.lang.String[] identifiers,
java.lang.String[] messages)
Prepare the class to provide internationalisation functions. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TxtBaseClass
public TxtBaseClass()
prepare
public static void prepare(java.lang.String aLanguage,
RobustReaderIF reader,
TxtBaseClass txtBase,
java.lang.String[] identifiers,
java.lang.String[] messages)
- Prepare the class to provide internationalisation functions. This should
be called by the setLanguage method. If the language is not English ('en') then
this method will attempt to read a message file (named 'messages.XX', where
XX is the language identifier) and parse it for messages. The messages are
then put in replacement for their originals in the supplied message arrays.
- Parameters:
aLanguage
- The language identifier string (for instance 'en', 'fr', 'de')reader
- A RobustReader for retrieving message files.txtBase
- The Txt class to update with the given languageidentifiers
- The message identifier array for message stringsmessages
- The message array
parseGroup
public static void parseGroup(SettingsGroup group,
java.lang.String[] identifiers,
java.lang.String[] messages)
get
public static java.lang.String get(int message)
get
public static java.lang.String get(int message,
java.lang.String replacement)
get
public static java.lang.String get(int message,
int replacement)
get
public static java.lang.String get(int message,
java.lang.String[] replacements)
doReplacements
public static java.lang.String doReplacements(java.lang.String message,
java.lang.String[] replacements)