|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object TranslatorImpl
public final class TranslatorImpl
Implementation of Translator
, required by WEB4J.
This implementation uses a database to store translations. As part of
StartupTasks
, the translations are read()
, and cached in
an in-memory structure, which is used to perform the actual runtime look up of translations.
This class can also help to find items that need translation, simply by exercising the application. The steps are as follows :
Translator
for a definition of 'base text').
stopRecordingUnknowns()
is then called. This class will stop recording unknowns,
and flush all existing unknowns to the database.
read()
is called to refresh the in-memory translations.
startRecordingUnknowns()
to repeat the process.
The above can be performed both during application development and during production, to find items that may have been missed. Screens are provided for all of the above tasks.
The start/stop action for recording unknowns is global, and applies to all users. If more than one person is simultaneously working on finding and evaluating unknown base text, then they should coordinate their efforts, to know when recording is on/off.
Constructor Summary | |
---|---|
TranslatorImpl()
|
Method Summary | |
---|---|
String |
get(String aBaseText,
Locale aLocale)
Look up the translation for aBaseText and aLocale. |
static Integer |
getNumTranslations()
Return the number of translations. |
static boolean |
isRecording()
Return true only if this class is currently recording unknown base text. |
static void |
read()
Look up all translations from a database, and store them in a static member. |
static void |
startRecordingUnknowns()
Start recording unknown base text. |
static void |
stopRecordingUnknowns()
Stop recording of unknown base text, and persist unknown items to the database. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TranslatorImpl()
Method Detail |
---|
public static void read() throws DAOException
Must be called by StartupTasks
. May also be called
after startup, to refresh the data.
DAOException
public static Integer getNumTranslations()
public static void startRecordingUnknowns() throws DAOException
Recording can start only if :
Items are recorded to an in-memory structure only. They are saved to the database by
calling stopRecordingUnknowns()
.
DAOException
public static void stopRecordingUnknowns() throws DAOException
This method fails if this class is not already recording.
DAOException
public static boolean isRecording()
public String get(String aBaseText, Locale aLocale)
If aBaseText is not known, or if there is no explicit translation for that
Locale
, then return aBaseText as is.
If aBaseText is not known, and this class is 'recording', then it is added to the unknown items.
get
in interface Translator
|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |