eZ Publish  [trunk]
eZTSTranslator Class Reference
+ Inheritance diagram for eZTSTranslator:
+ Collaboration diagram for eZTSTranslator:

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

 $BuildCache
 $CachedMessages
 $File
 $Messages
 $UseCache
const EXPIRY_KEY = 'ts-translation-cache'
 Translation expiry key used by eZExpiryHandler to manage translation caches.

Detailed Description

Definition at line 16 of file eztstranslator.php.


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

Definition at line 733 of file eztstranslator.php.

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

Definition at line 24 of file eztstranslator.php.

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

Definition at line 681 of file eztstranslator.php.

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.

Definition at line 541 of file eztstranslator.php.

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.

Definition at line 558 of file eztstranslator.php.

Referenced by translate().

Handles a DOM Context node and the messages it contains.

Parameters:
DOMNode$context
Returns:
bool

Definition at line 386 of file eztstranslator.php.

Referenced by loadTranslationFile().

eZTSTranslator::handleMessageNode ( contextName,
message 
)

Handles a translation message DOM node.

Parameters:
string$contextName
DOMNode$message

Definition at line 448 of file eztstranslator.php.

Referenced by handleContextNode().

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

Definition at line 86 of file eztstranslator.php.

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

Definition at line 53 of file eztstranslator.php.

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

Definition at line 620 of file eztstranslator.php.

Referenced by handleMessageNode().

eZTSTranslator::keyTranslate ( key) [virtual]

Returns the translation for a translation md5 key.

Parameters:
string$key
Returns:
string|false

Implements eZTranslatorHandler.

Definition at line 578 of file eztstranslator.php.

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

Definition at line 97 of file eztstranslator.php.

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

Definition at line 115 of file eztstranslator.php.

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

Definition at line 651 of file eztstranslator.php.

Removes the translation message with the key $key.

Parameters:
string$keyThe translation md5 key
Returns:
bool true if the message was removed, false otherwise

Definition at line 668 of file eztstranslator.php.

static eZTSTranslator::resetGlobals ( ) [static]

Resets the in-memory translations table.

Returns:
void

Definition at line 719 of file eztstranslator.php.

Referenced by expireCache().

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

Translates a context + source + comment.

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

Implements eZTranslatorHandler.

Definition at line 596 of file eztstranslator.php.

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

Definition at line 371 of file eztstranslator.php.

Referenced by loadTranslationFile().


Member Data Documentation

eZTSTranslator::$BuildCache

Definition at line 756 of file eztstranslator.php.

eZTSTranslator::$CachedMessages

Definition at line 757 of file eztstranslator.php.

eZTSTranslator::$File

Definition at line 754 of file eztstranslator.php.

eZTSTranslator::$Messages

Definition at line 753 of file eztstranslator.php.

eZTSTranslator::$UseCache

Definition at line 755 of file eztstranslator.php.

const eZTSTranslator::EXPIRY_KEY = 'ts-translation-cache'

Translation expiry key used by eZExpiryHandler to manage translation caches.

Definition at line 762 of file eztstranslator.php.


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