class TwigNodeTrans extends Node (View source)

A class that defines the Twig 'trans' tag for Drupal.

This Twig extension was originally based on Twig i18n extension. It has been severely modified to work properly with the complexities of the Drupal translation system.

Methods

__construct(Node $body, Node $plural = NULL, AbstractExpression $count = NULL, AbstractExpression $options = NULL, $lineno, $tag = NULL)

{@inheritdoc}

compile(Compiler $compiler)

{@inheritdoc}

array
compileString(Node $body)

Extracts the text and tokens for the "trans" tag.

Details

__construct(Node $body, Node $plural = NULL, AbstractExpression $count = NULL, AbstractExpression $options = NULL, $lineno, $tag = NULL)

{@inheritdoc}

Parameters

Node $body
Node $plural
AbstractExpression $count
AbstractExpression $options
$lineno
$tag

compile(Compiler $compiler)

{@inheritdoc}

Parameters

Compiler $compiler

protected array compileString(Node $body)

Extracts the text and tokens for the "trans" tag.

Parameters

Node $body

The node to compile.

Return Value

array

Returns an array containing the two following parameters:

  • string $text The extracted text.
  • array $tokens The extracted tokens as new \Twig\Node\Expression\TempNameExpression instances.