Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZTSTranslator Class Reference
Inheritance diagram for eZTSTranslator:

## Public Member Functions
| __construct ( $locale, $filename=null, $useCache=true)
| hasInitializedContext ( $context)
| load ( $requestedContext)
| loadTranslationFile ( $locale, $filename, $requestedContext)
| handleContextNode ( $context)
| handleMessageNode ( $contextName, $message)
| findKey ( $key)
| findMessage ( $context, $source, $comment=null)
| keyTranslate ( $key)
| translate ( $context, $source, $comment=null)
| insert ( $context, $source, $translation, $comment=null)
| remove ( $context, $source, $message=null)
| removeKey ( $key)
Public Member Functions inherited from eZTranslatorHandler
| __construct ( $is_key_based)
| isKeyBased ()

## Static Public Member Functions
static | initialize ( $context, $locale, $filename, $useCache=true)
static | validateDOMTree ( $tree)
static | fetchList ( $localeList=array())
static | resetGlobals ()
static | expireCache ( $timestamp=false, $locale=null)

## Public Attributes
| $Messages
| $File
| $UseCache
| $BuildCache
| $CachedMessages
| $Locale
| $HasRestoredCache
| $RootCache
const | EXPIRY_KEY = 'ts-translation-cache'
Public Attributes inherited from eZTranslatorHandler
| $IsKeyBased

## Detailed Description

Definition at line 16 of file eztstranslator.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZTSTranslator::__construct | ( |  | $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.

## Member Function Documentation

## ◆ expireCache()

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

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.

Returns
  void

Definition at line 733 of file eztstranslator.php.

References resetGlobals().

Referenced by eZCache\clearTSTranslationCache().

## ◆ fetchList()

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.

References eZDir\findSubdirs(), eZDir\findSubitems(), and eZFile\suffix().

## ◆ findKey()

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().

## ◆ findMessage()

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.

References findKey(), and eZTranslatorManager\instance().

Referenced by translate().

## ◆ handleContextNode()

eZTSTranslator::handleContextNode | ( |  | $context | ) |

Handles a DOM Context node and the messages it contains

Parameters

  DOMNode | $context |

Returns
  bool

Definition at line 386 of file eztstranslator.php.

References handleMessageNode(), and eZDebug\writeError().

Referenced by loadTranslationFile().

## ◆ handleMessageNode()

eZTSTranslator::handleMessageNode | ( |  | $contextName,
|  |  | $message
| ) |  |

Handles a translation message DOM node

Parameters

  string | $contextName |
  DOMNode | $message |

Definition at line 448 of file eztstranslator.php.

References insert(), eZTextCodec\instance(), and eZDebug\writeError().

Referenced by handleContextNode().

## ◆ hasInitializedContext()

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

Definition at line 86 of file eztstranslator.php.

## ◆ initialize()

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.

References eZDebug\accumulatorStart(), eZDebug\accumulatorStop(), eZDebug\createAccumulatorGroup(), and eZTranslatorManager\instance().

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

## ◆ insert()

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.

References eZTranslatorManager\instance().

Referenced by handleMessageNode().

## ◆ keyTranslate()

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.

References findKey().

## ◆ load()

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.

References loadTranslationFile().

## ◆ loadTranslationFile()

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

@access private

Parameters

  string | $locale |
  string | $filename |
  string | $requestedContext |

Returns
  bool The operation status, true or false

Definition at line 115 of file eztstranslator.php.

References $HasRestoredCache, eZDebug\accumulatorStart(), eZDebug\accumulatorStop(), eZExtension\baseDirectory(), eZTranslationCache\canRestoreCache(), eZTranslationCache\contextCache(), handleContextNode(), eZTextCodec\internalCharset(), eZDir\path(), eZTranslationCache\restoreCache(), eZTranslationCache\setContextCache(), eZTranslationCache\storeCache(), validateDOMTree(), eZDebugSetting\writeDebug(), eZDebugSetting\writeNotice(), and eZDebug\writeWarning().

Referenced by load().

## ◆ remove()

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.

References eZTranslatorManager\instance().

## ◆ removeKey()

eZTSTranslator::removeKey | ( |  | $key | ) |

Removes the translation message with the key $key.

Parameters

  string | $key | The translation md5 key

Returns
  bool true if the message was removed, false otherwise

Definition at line 668 of file eztstranslator.php.

## ◆ resetGlobals()

static eZTSTranslator::resetGlobals | ( |  | ) |
| static

Resets the in-memory translations table

Returns
  void

Definition at line 719 of file eztstranslator.php.

Referenced by expireCache(), and eZTranslatorManager\resetTranslations().

## ◆ translate()

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.

References findMessage().

## ◆ validateDOMTree()

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

## ◆ $BuildCache

eZTSTranslator::$BuildCache

Definition at line 754 of file eztstranslator.php.

## ◆ $CachedMessages

eZTSTranslator::$CachedMessages

Definition at line 755 of file eztstranslator.php.

## ◆ $File

eZTSTranslator::$File

Definition at line 752 of file eztstranslator.php.

## ◆ $HasRestoredCache

eZTSTranslator::$HasRestoredCache

Definition at line 757 of file eztstranslator.php.

Referenced by loadTranslationFile().

## ◆ $Locale

eZTSTranslator::$Locale

Definition at line 756 of file eztstranslator.php.

## ◆ $Messages

eZTSTranslator::$Messages

Definition at line 751 of file eztstranslator.php.

## ◆ $RootCache

eZTSTranslator::$RootCache

Definition at line 758 of file eztstranslator.php.

## ◆ $UseCache

eZTSTranslator::$UseCache

Definition at line 753 of file eztstranslator.php.

## ◆ EXPIRY_KEY

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

Translation expiry key used by eZExpiryHandler to manage translation caches

Definition at line 763 of file eztstranslator.php.

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

- eztstranslator.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.