eZ Publish Community Project (Legacy Stack) 2013.4
Class

eZTSTranslator

class eZTSTranslator extends eZTranslatorHandler

Provides internationalization using XML (.ts) files

Constants

EXPIRY_KEY

Translation expiry key used by eZExpiryHandler to manage translation caches

Properties

$IsKeyBased
array $Messages Contains the hash table with message translations
$File
$UseCache
$BuildCache
$CachedMessages

Methods

eZTranslatorHandler($is_key_based)

from eZTranslatorHandler
isKeyBased()

from eZTranslatorHandler
array|false findKey(string $key)

Returns the message that matches a translation md5 key

array|false findMessage(string $context, string $source, string $comment = null)

Returns the message that matches a context / source / comment

string|false translate(string $context, string $source, string $comment = null)

Translates a context + source + comment

string|false keyTranslate(string $key)

Returns the translation for a translation md5 key

eZTSTranslator(string $locale, string $filename = null, bool $useCache = true)

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

bool hasInitializedContext(string $context)

Checks if a context has been initialized (cached)

bool load(string $requestedContext)

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

bool loadTranslationFile(string $locale, string $filename, string $requestedContext)

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

bool handleContextNode(DOMNode $context)

Handles a DOM Context node and the messages it contains

handleMessageNode(string $contextName, DOMNode $message)

Handles a translation message DOM node

string insert(string $context, string $source, string $translation, string $comment = null)

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

bool remove(string $context, string $source, string $message = null)

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

bool removeKey(string $key)

Removes the translation message with the key $key.

static void expireCache(int $timestamp = false, string $locale = null)

Expires the translation cache

Details

in eZTranslatorHandler at line 23
public eZTranslatorHandler($is_key_based)

Parameters

$is_key_based

in eZTranslatorHandler at line 32
public isKeyBased()

at line 541
public array|false findKey(string $key)

Returns the message that matches a translation md5 key

Parameters

string $key

Return Value

array|false The message, as an array, or false if not found

at line 558
public array|false findMessage(string $context, string $source, string $comment = null)

Returns the message that matches a context / source / comment

Parameters

string $context
string $source
string $comment

Return Value

array|false The message, as an array, or false if not found

at line 596
public string|false translate(string $context, string $source, string $comment = null)

Translates a context + source + comment

Parameters

string $context
string $source
string $comment

Return Value

string|false

at line 578
public string|false keyTranslate(string $key)

Returns the translation for a translation md5 key

Parameters

string $key

Return Value

string|false

at line 24
public eZTSTranslator(string $locale, string $filename = null, bool $useCache = true)

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

Parameters

string $locale
string $filename
bool $useCache

at line 86
public bool hasInitializedContext(string $context)

Checks if a context has been initialized (cached)

Parameters

string $context

Return Value

bool True if the context was initialized before, false if it wasn't

at line 97
public bool load(string $requestedContext)

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

Parameters

string $requestedContext

Return Value

bool True if load was successful, false otherwise

at line 115
public bool loadTranslationFile(string $locale, string $filename, string $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

Parameters

string $locale
string $filename
string $requestedContext

Return Value

bool The operation status, true or false

at line 386
public bool handleContextNode(DOMNode $context)

Handles a DOM Context node and the messages it contains

Parameters

DOMNode $context

Return Value

bool

at line 448
public handleMessageNode(string $contextName, DOMNode $message)

Handles a translation message DOM node

Parameters

string $contextName
DOMNode $message

at line 620
public string insert(string $context, string $source, string $translation, string $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

Return Value

string The translation (md5) key

at line 651
public bool remove(string $context, string $source, string $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

Return Value

bool true if the message was removed, false otherwise

at line 668
public bool removeKey(string $key)

Removes the translation message with the key $key.

Parameters

string $key The translation md5 key

Return Value

bool true if the message was removed, false otherwise

at line 733
static public void expireCache(int $timestamp = false, string $locale = null)

Expires the translation cache

Parameters

int $timestamp An optional timestamp cache should be exired from. Current timestamp used by default
string $locale Optional translation's locale to expire specifically. Expires global ts cache by default.

Return Value

void