protected function compileString(Twig_NodeList $body) { $msg = ''; $vars = array(); foreach ($body->getNodes() as $i => $node) { if ($node instanceof Twig_Node_Text) { $msg .= $node->getData(); } elseif ($node instanceof Twig_Node_Print && $node->getExpression() instanceof Twig_Node_Expression_Name) { $msg .= sprintf('%%%s%%', $node->getExpression()->getName()); $vars[] = $node->getExpression(); } else { throw new Twig_SyntaxError(sprintf('The text to be translated with "trans" can only contain references to simple variable'), $this->lineno); } } return array(trim($msg), $vars); }