lib/ezi18n/classes/eztstranslator.php

Show: inherited
Table of Contents

File containing the eZTSTranslator class.

Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
License
eZ Business Use License Agreement Version 2.0  
Package
lib  
Subpackage
i18n  
Version
4.6.0  

\eZTSTranslator

Package: lib\i18n

Provides internationalization using XML (.ts) files

Parent(s)
\eZTranslatorHandler
Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
Version
4.6.0  

Constants

Constant  EXPIRY_KEY = 'ts-translation-cache'

Translation expiry key used by eZExpiryHandler to manage translation caches

Properties

Propertypublic  $BuildCache= ''
Details
Type
n/a
Propertypublic  $CachedMessages= ''
Details
Type
n/a
Propertypublic  $File= ''
Details
Type
n/a
Propertypublic  $IsKeyBased= ''
inheritedInherited from: \eZTranslatorHandler::$$IsKeyBased
Details
Type
n/a
Inherited_from
\eZTranslatorHandler::$$IsKeyBased  
Propertypublicarray  $Messages= ''

Contains the hash table with message translations

Details
Type
array
Propertypublic  $UseCache= ''
Details
Type
n/a

Methods

methodpubliceZTSTranslator( string $locale, string $filename = null, bool $useCache = true ) : void

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

Parameters
Name Type Description
$locale string
$filename string
$useCache bool
methodpubliceZTranslatorHandler(  $is_key_based ) : void
Parameters
Name Type Description
$is_key_based
methodpublicexpireCache( int $timestamp = false, string $locale = null ) : void
static

Expires the translation cache

Parameters
Name Type Description
$timestamp int

An optional timestamp cache should be exired from. Current timestamp used by default

$locale string

Optional translation's locale to expire specifically. Expires global ts cache by default.

methodpublicfetchList(  $localeList = array() ) : \array(
static

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

Parameters
Name Type Description
$localeList
Returns
Type Description
\array( eZTSTranslator ) list of eZTranslator objects representing available translations
methodpublicfindKey( string $key ) : array | false

Returns the message that matches a translation md5 key

Parameters
Name Type Description
$key string
Returns
Type Description
array | false The message, as an array, or false if not found
methodpublicfindMessage( string $context, string $source, string $comment = null ) : array | false

Returns the message that matches a context / source / comment

Parameters
Name Type Description
$context string
$source string
$comment string
Returns
Type Description
array | false The message, as an array, or false if not found
methodpublichandleContextNode( \DOMNode $context ) : bool

Handles a DOM Context node and the messages it contains

Parameters
Name Type Description
$context \DOMNode
Returns
Type Description
bool
methodpublichandleMessageNode( string $contextName, \DOMNode $message ) : void

Handles a translation message DOM node

Parameters
Name Type Description
$contextName string
$message \DOMNode
methodpublichasInitializedContext( string $context ) : bool

Checks if a context has been initialized (cached)

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

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

Parameters
Name Type Description
$context string
$locale string
$filename string
$useCache bool
Returns
Type Description
\eZTSTranslator
methodpublicinsert( string $context, string $source, string $translation, string $comment = null ) : string

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
Name Type Description
$context string
$source string
$translation string
$comment string
Returns
Type Description
string The translation (md5) key
methodpublicisKeyBased( ) : void
inherited

Inherited from: \eZTranslatorHandler::isKeyBased()
methodpublickeyTranslate( string $key ) : string | false

Returns the translation for a translation md5 key

Parameters
Name Type Description
$key string
Returns
Type Description
string | false
methodpublicload( string $requestedContext ) : bool

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

Parameters
Name Type Description
$requestedContext string
Returns
Type Description
bool True if load was successful, false otherwise
methodpublicloadTranslationFile( string $locale, string $filename, string $requestedContext ) : bool

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
Name Type Description
$locale string
$filename string
$requestedContext string
Returns
Type Description
bool The operation status, true or false
Details
Access
private  
methodpublicremove( string $context, string $source, string $message = null ) : bool

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

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

Parameters
Name Type Description
$context string
$source string
$message string
Returns
Type Description
bool true if the message was removed, false otherwise
methodpublicremoveKey( string $key ) : bool

Removes the translation message with the key $key.

Parameters
Name Type Description
$key string

The translation md5 key

Returns
Type Description
bool true if the message was removed, false otherwise
methodpublicresetGlobals( ) : void
static

Resets the in-memory translations table

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

Translates a context + source + comment

Parameters
Name Type Description
$context string
$source string
$comment string
Returns
Type Description
string | false
methodpublicvalidateDOMTree( \DOMDocument $tree ) : bool
static

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

Parameters
Name Type Description
$tree \DOMDocument
Returns
Type Description
bool True if the DOMDocument is valid, false otherwise
Documentation was generated by DocBlox 0.18.1.