Path

ez components / documentation / api reference / 2008.1beta1 / templatetranslationtiein


eZ Components 2008.1beta1

TemplateTranslationTiein: ezcTemplateTranslationStringExtracter

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

Class: ezcTemplateTranslationStringExtracter

A visiter that can be used to extract translatable strings from a template. [source]
Implements the ezcTemplateTstNodeVisiter interface for visiting the nodes and extracting translatable strings from them. It can be used like:
 1.  <?php
 2.  $file dirname__FILE__ '/test_files/test.ezt';
 3.  $source new ezcTemplateSourceCode$file$file );
 4.  $source->load();
 5.  
 6.  $parser new ezcTemplateParser$sourcenew ezcTemplate() );
 7.  $tst $parser->parseIntoNodeTree();
 8.  
 9.  $et new ezcTemplateTranslationStringExtracter$parser );
10.  $eted $tst->accept$et );
11.  
12.  $tr $et->getTranslation();
13.  ?>

Parents

ezcTemplateTstWalker
   |
   --ezcTemplateTranslationStringExtracter

Member Variables

protected array(string=>array(ezcTranslationData) $strings
Contans an array of arrays, where the key is the context, and the value an array of ezcTranslationData elements.
public string $translationContext
Contains the active default translation context

Method Summary

public ezcTemplateTranslationStringExtracter __construct( $parser )
Initialize the transformer, after this send this object to the accept() method on a node.
public array(string=>array(ezcTranslationData)) getStrings( )
Returns an array of translation objects indexed by context
public array(string=>ezcTranslation) getTranslation( )
Returns an array of translation datamaps indexed by context
public string visitLiteralTstNode( $type )
Transform the literal from a TST node to a string.
public void visitTranslationContextTstNode( $node )
visitTranslationContextTstNode
public void visitTranslationTstNode( $node )
visitTranslationTstNode

Methods

__construct

ezcTemplateTranslationStringExtracter __construct( $parser )
Initialize the transformer, after this send this object to the accept() method on a node.

Parameters

Name Type Description
$parser ezcTemplateParser The main parser object.

getStrings

array(string=>array(ezcTranslationData)) getStrings( )
Returns an array of translation objects indexed by context

getTranslation

array(string=>ezcTranslation) getTranslation( )
Returns an array of translation datamaps indexed by context

visitLiteralTstNode

string visitLiteralTstNode( $type )
Transform the literal from a TST node to a string.
The text will transformed by processing the escape sequences according to the type which is either ezcTemplateLiteralTstNode::SINGLE_QUOTE or ezcTemplateLiteralTstNode::DOUBLE_QUOTE.

Parameters

Name Type Description
$type ezcTemplateLiteralTstNode  

See also:

ezcTemplateStringTool::processDoubleQuotedEscapes(), ezcTemplateStringTool::processSingleQuotedEscapes().


visitTranslationContextTstNode

void visitTranslationContextTstNode( $node )
visitTranslationContextTstNode

Parameters

Name Type Description
$node ezcTemplateTranslationContextTstNode  

visitTranslationTstNode

void visitTranslationTstNode( $node )
visitTranslationTstNode

Parameters

Name Type Description
$node ezcTemplateTranslationTstNode  

Last updated: Tue, 27 May 2008