eZPublish  4.7
eZTSTranslator Class Reference
+ Inheritance diagram for eZTSTranslator:
+ Collaboration diagram for eZTSTranslator:

Public Member Functions

 eZTSTranslator ($locale, $filename=null, $useCache=true)
 Constructs the translator and loads the translation file $file if it is set and exists. More...
 
 findKey ($key)
 Returns the message that matches a translation md5 key. More...
 
 findMessage ($context, $source, $comment=null)
 Returns the message that matches a context / source / comment. More...
 
 handleContextNode ($context)
 Handles a DOM Context node and the messages it contains. More...
 
 handleMessageNode ($contextName, $message)
 Handles a translation message DOM node. More...
 
 hasInitializedContext ($context)
 Checks if a context has been initialized (cached) More...
 
 insert ($context, $source, $translation, $comment=null)
 Inserts the translation $translation for the context $context and source $source as a translation message. More...
 
 keyTranslate ($key)
 Returns the translation for a translation md5 key. More...
 
 load ($requestedContext)
 Tries to load the context $requestedContext for the translation and returns true if was successful. More...
 
 loadTranslationFile ($locale, $filename, $requestedContext)
 Loads a translation file Will load from cache if possible, or generate cache if needed. More...
 
 remove ($context, $source, $message=null)
 Removes the translation message with context $context and source $source. More...
 
 removeKey ($key)
 Removes the translation message with the key $key. More...
 
 translate ($context, $source, $comment=null)
 Translates a context + source + comment. More...
 
- Public Member Functions inherited from eZTranslatorHandler
 eZTranslatorHandler ($is_key_based)
 
 isKeyBased ()
 

Static Public Member Functions

static expireCache ($timestamp=false, $locale=null)
 Expires the translation cache. More...
 
static fetchList ($localeList=array())
 Fetches the list of available translations, as an eZTSTranslator for each translation. More...
 
static initialize ($context, $locale, $filename, $useCache=true)
 Initialize the ts translator and context if this is not already done. More...
 
static resetGlobals ()
 Resets the in-memory translations table. More...
 
static validateDOMTree ($tree)
 Validates the DOM tree $tree and returns true if it is correct. More...
 

Public Attributes

 $BuildCache
 
 $CachedMessages
 
 $File
 
 $Messages
 
 $UseCache
 
const EXPIRY_KEY = 'ts-translation-cache'
 Translation expiry key used by eZExpiryHandler to manage translation caches. More...
 
- Public Attributes inherited from eZTranslatorHandler
 $IsKeyBased
 Tells whether the handler is key based or not. More...
 

Member Function Documentation

static eZTSTranslator::expireCache (   $timestamp = false,
  $locale = null 
)
static

Expires the translation cache.

Parameters
int$timestampAn optional timestamp cache should be exired from. Current timestamp used by default
string$localeOptional translation's locale to expire specifically. Expires global ts cache by default.
Returns
void

Referenced by eZCache\clearTSTranslationCache().

eZTSTranslator::eZTSTranslator (   $locale,
  $filename = null,
  $useCache = true 
)

Constructs the translator and loads the translation file $file if it is set and exists.

Parameters
string$locale
string$filename
bool$useCache

Referenced by fetchList(), and initialize().

static eZTSTranslator::fetchList (   $localeList = array())
static

Fetches the list of available translations, as an eZTSTranslator for each translation.

Parameters
array$localList
Returns
array( eZTSTranslator ) list of eZTranslator objects representing available translations
eZTSTranslator::findKey (   $key)
virtual

Returns the message that matches a translation md5 key.

Parameters
string$key
Returns
array|false The message, as an array, or false if not found

Implements eZTranslatorHandler.

Referenced by findMessage(), and keyTranslate().

eZTSTranslator::findMessage (   $context,
  $source,
  $comment = null 
)
virtual

Returns the message that matches a context / source / comment.

Parameters
string$context
string$source
string$comment
Returns
array|false The message, as an array, or false if not found

Implements eZTranslatorHandler.

Referenced by translate().

eZTSTranslator::handleContextNode (   $context)

Handles a DOM Context node and the messages it contains.

Parameters
DOMNode$context
Returns
bool

Referenced by loadTranslationFile().

eZTSTranslator::handleMessageNode (   $contextName,
  $message 
)

Handles a translation message DOM node.

Parameters
string$contextName
DOMNode$message

Referenced by handleContextNode().

eZTSTranslator::hasInitializedContext (   $context)

Checks if a context has been initialized (cached)

Parameters
string$context
Returns
bool True if the context was initialized before, false if it wasn't
static eZTSTranslator::initialize (   $context,
  $locale,
  $filename,
  $useCache = true 
)
static

Initialize the ts translator and context if this is not already done.

Parameters
string$context
string$locale
string$filename
bool$useCache
Returns
eZTSTranslator

Referenced by eZi18nOperator\i18nTrans(), and ezpI18n\translateText().

eZTSTranslator::insert (   $context,
  $source,
  $translation,
  $comment = null 
)

Inserts the translation $translation for the context $context and source $source as a translation message.

Returns the key for the message. If $comment is non-null it will be included in the message.

If the translation message exists no new message is created and the existing key is returned.

Parameters
string$context
string$source
string$translation
string$comment
Returns
string The translation (md5) key

Referenced by handleMessageNode().

eZTSTranslator::keyTranslate (   $key)
virtual

Returns the translation for a translation md5 key.

Parameters
string$key
Returns
string|false

Implements eZTranslatorHandler.

eZTSTranslator::load (   $requestedContext)

Tries to load the context $requestedContext for the translation and returns true if was successful.

Parameters
string$requestedContext
Returns
bool True if load was successful, false otherwise
eZTSTranslator::loadTranslationFile (   $locale,
  $filename,
  $requestedContext 
)

Loads a translation file Will load from cache if possible, or generate cache if needed.

Also checks for translation files expiry based on mtime if RegionalSettings.TranslationCheckMTime is enabled

private

Parameters
string$locale
string$filename
string$requestedContext
Returns
bool The operation status, true or false

Referenced by load().

eZTSTranslator::remove (   $context,
  $source,
  $message = null 
)

Removes the translation message with context $context and source $source.

If you have the translation key use removeKey() instead.

Parameters
string$context
string$source
string$message
Returns
bool true if the message was removed, false otherwise
eZTSTranslator::removeKey (   $key)

Removes the translation message with the key $key.

Parameters
string$keyThe translation md5 key
Returns
bool true if the message was removed, false otherwise
static eZTSTranslator::resetGlobals ( )
static

Resets the in-memory translations table.

Returns
void

Referenced by eZTranslatorManager\resetTranslations().

eZTSTranslator::translate (   $context,
  $source,
  $comment = null 
)
virtual

Translates a context + source + comment.

Parameters
string$context
string$source
string$comment
Returns
string|false

Implements eZTranslatorHandler.

static eZTSTranslator::validateDOMTree (   $tree)
static

Validates the DOM tree $tree and returns true if it is correct.

Parameters
DOMDocument$tree
Returns
bool True if the DOMDocument is valid, false otherwise

Referenced by loadTranslationFile().

Member Data Documentation

eZTSTranslator::$BuildCache
eZTSTranslator::$CachedMessages
eZTSTranslator::$File
eZTSTranslator::$Messages
eZTSTranslator::$UseCache
const eZTSTranslator::EXPIRY_KEY = 'ts-translation-cache'

Translation expiry key used by eZExpiryHandler to manage translation caches.


The documentation for this class was generated from the following file: