Apache Zeta Components - high quality PHP components

Apache Zeta Components Manual :: Docs For Class ezcTemplateTranslationStringExtracter

TemplateTranslationTiein::ezcTemplateTranslationStringExtracter

Class ezcTemplateTranslationStringExtracter

A visiter that can be used to extract translatable strings from a template.

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( $source, new ezcTemplate() );
  7.  $tst = $parser->parseIntoNodeTree();
  8.  
  9.  $et = new ezcTemplateTranslationStringExtracter( $parser );
  10.  $eted = $tst->accept( $et );
  11.  
  12.  $tr = $et->getTranslation();
  13.  ?>

Source for this file: /TemplateTranslationTiein/src/visitors/string_extracter.php

ezcTemplateTstWalker
   |
   --ezcTemplateTranslationStringExtracter
Version:   //autogen//

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

visitTranslationContextTstNode

void visitTranslationContextTstNode( $node )

visitTranslationContextTstNode

Parameters:
Name Type Description
$node ezcTemplateTranslationContextTstNode

visitTranslationTstNode

void visitTranslationTstNode( $node )

visitTranslationTstNode

Parameters:
Name Type Description
$node ezcTemplateTranslationTstNode
Documentation generated by phpDocumentor 1.4.3