/** * @param key - unescaped string (not PHP code) for the key */ private function _getTranslationCode(PHPTAL_Php_CodeWriter $codewriter, $key) { $code = ''; if (preg_match_all('/\\$\\{(.*?)\\}/', $key, $m)) { array_shift($m); $m = array_shift($m); foreach ($m as $name) { $code .= "\n" . '$_translator->setVar(' . $codewriter->str($name) . ',' . PHPTAL_Php_TalesInternal::compileToPHPExpression($name) . ');'; // allow more complex TAL expressions } $code .= "\n"; } // notice the false boolean which indicate that the html is escaped // elsewhere looks like an hack doesn't it ? :) $code .= 'echo ' . $codewriter->escapeCode('$_translator->translate(' . $codewriter->str($key) . ', false)'); return $code; }