本文整理汇总了PHP中PHPTAL_Php_CodeWriter::getTranslatorReference方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL_Php_CodeWriter::getTranslatorReference方法的具体用法?PHP PHPTAL_Php_CodeWriter::getTranslatorReference怎么用?PHP PHPTAL_Php_CodeWriter::getTranslatorReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPTAL_Php_CodeWriter
的用法示例。
在下文中一共展示了PHPTAL_Php_CodeWriter::getTranslatorReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after
public function after(PHPTAL_Php_CodeWriter $codewriter)
{
// restore source
$code = $codewriter->getTranslatorReference() . '->setSource(array_pop($_i18n_sources))';
$codewriter->pushCode($code);
}
示例2: _getTranslationCode
/**
* @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" . $codewriter->getTranslatorReference() . '->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($codewriter->getTranslatorReference() . '->translate(' . $codewriter->str($key) . ', false)');
return $code;
}
示例3: after
public function after(PHPTAL_Php_CodeWriter $codewriter)
{
$codewriter->pushCode($codewriter->getTranslatorReference() . '->setVar(' . $codewriter->str($this->expression) . ', ob_get_clean())');
}