Path

ez components / documentation / api reference / 2009.1.2 / translation


eZ Components 2009.1.2

Translation: ezcTranslationManager

[ Tutorial ] [ Linguist format ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcTranslationManager

ezcTranslationManager handles a specific translation file and provides functionality to apply filters and retrieve contexts and translations. [source]
The following example shows typical usage:
 1.  <?php
 2.  $a new ezcTranslationTsBackend'tests/translations' );
 3.  $a->setOptionsarray 'format' => '[LOCALE].xml' ) );
 4.  
 5.  $b new ezcTranslationManager$a );
 6.  $b->addFilterezcTranslationComplementEmptyFilter::getInstance() );
 7.  $b->addFilterezcTranslationBorkFilter::getInstance() );
 8.  
 9.  // Asks the backend for data, runs the attached filter, and creates a
10.  // Translation object
11.   $tln1 $b->getContext'nl_NL''design/admin/content/browse_copy_node' );
12.  
13.  // Returns the localized string belonging to key "key", the filter has already
14.  // been applied to it. Possible parameters can be passed as associative array
15.  // as optional second parameter.
16.   $string $tln1->getTranslation'Choose location for copy of <%object_name>'array'object_name' => 'Foo' ) );
17.  ?>

Method Summary

public ezcTranslationManager __construct( $backend )
Constructs an ezcTranslationManager object
public void addFilter( $filter )
Adds a filter to the filter list.
public ezcTranslation getContext( $locale, $context )
Returns the translations for the $context context and the locale $locale.

Methods

__construct

ezcTranslationManager __construct( ezcTranslationBackend $backend )
Constructs an ezcTranslationManager object
This constructor constructs a new ezcTranslationManager object. The only parameter is a class that implements the ezcTranslationBackendInterface.

Parameters

Name Type Description
$backend ezcTranslationBackend An instance of a translation backend.

addFilter

void addFilter( ezcTranslationFilter $filter )
Adds a filter to the filter list.
This methods adds the passed filter object to the list of $filters that will be applied on every context before being returned by getContext().

Parameters

Name Type Description
$filter ezcTranslationFilter  

getContext

ezcTranslation getContext( string $locale, string $context )
Returns the translations for the $context context and the locale $locale.
This methods reads the context data from the backend and applies the filters before returning the translation map as part of the ezcTranslation object that it returns.

Parameters

Name Type Description
$locale string  
$context string  

Last updated: Tue, 01 Sep 2009