Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
Fixes issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsammon authored and fabpot committed Jan 30, 2011
1 parent c6e8ba8 commit 6b0cc16
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/Twig/Extensions/Node/Trans.php
Expand Up @@ -104,19 +104,25 @@ protected function compileString(Twig_NodeInterface $body)
return array($body, array());
}

$msg = '';
$vars = array();
foreach ($body as $node) {
if ($node instanceof Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof Twig_Node_Expression_Filter) {
$n = $n->getNode('node');

if (count($body)) {
$msg = '';

foreach ($body as $node) {
if ($node instanceof Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof Twig_Node_Expression_Filter) {
$n = $n->getNode('node');
}
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else {
$msg .= $node->getAttribute('data');
}
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else {
$msg .= $node->getAttribute('data');
}
} else {
$msg = $body->getAttribute('data');
}

return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars);
Expand Down

0 comments on commit 6b0cc16

Please sign in to comment.