decideTransFork example

if ($stream->test('into')) {
                // {% trans into "fr" %}                 $stream->next();
                $locale = $this->parser->getExpressionParser()->parseExpression();
            } elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
                throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine()$stream->getSourceContext());
            }
        }

        // {% trans %}message{% endtrans %}         $stream->expect(Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse($this->decideTransFork(...), true);

        if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
            throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine()$stream->getSourceContext());
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new TransNode($body$domain$count$vars$locale$lineno$this->getTag());
    }

    public function decideTransFork(Token $token): bool
    {
Home | Imprint | This part of the site doesn't use cookies.