Fish & Chips Club 4.10.0.0

hirondelle.web4j.config
Class TranslatorImpl

Object
  extended by TranslatorImpl
All Implemented Interfaces:
Translator

public final class TranslatorImpl
extends Object
implements Translator

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 :

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

TranslatorImpl

public TranslatorImpl()
Method Detail

read

public static void read()
                 throws DAOException
Look up all translations from a database, and store them in a static member.

Must be called by StartupTasks. May also be called after startup, to refresh the data.

Throws:
DAOException

getNumTranslations

public static Integer getNumTranslations()
Return the number of translations.


startRecordingUnknowns

public static void startRecordingUnknowns()
                                   throws DAOException
Start recording unknown base text.

Recording can start only if :

Items are recorded to an in-memory structure only. They are saved to the database by calling stopRecordingUnknowns().

Throws:
DAOException

stopRecordingUnknowns

public static void stopRecordingUnknowns()
                                  throws DAOException
Stop recording of unknown base text, and persist unknown items to the database.

This method fails if this class is not already recording.

Throws:
DAOException

isRecording

public static boolean isRecording()
Return true only if this class is currently recording unknown base text.


get

public String get(String aBaseText,
                  Locale aLocale)
Look up the translation for aBaseText and 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.

Specified by:
get in interface Translator

Fish & Chips Club 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.26