本文整理汇总了PHP中PHPTAL::setTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL::setTranslator方法的具体用法?PHP PHPTAL::setTranslator怎么用?PHP PHPTAL::setTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPTAL
的用法示例。
在下文中一共展示了PHPTAL::setTranslator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processViewData
/**
* This method is used to process the data into the view and than return it to the main method that will handle what to do.
* It also uses buffer to handle that content.
*
* @author Klederson Bueno <klederson@klederson.com>
* @version 0.1a
*
* @param String $___phpBurnFilePath
* @param Array $__phpBurnData
* @return String
*/
public function processViewData($___phpBurnFilePath, $__phpBurnData)
{
$tpl = new PHPTAL($___phpBurnFilePath);
$tpl->setOutputMode(PHPTAL::HTML5);
$tr = new PHPTAL_GetTextTranslator();
// set language to use for this session (first valid language will
// be used)
$tr->setLanguage('pt_BR.utf8', 'pt_BR');
// register gettext domain to use
$tr->addDomain('system', SYS_BASE_PATH . 'locale');
// specify current domain
$tr->useDomain('system');
// tell PHPTAL to use our translator
$tpl->setTranslator($tr);
foreach ($__phpBurnData as $index => $value) {
if (is_string($value)) {
$value = PhpBURN_Views::lazyTranslate($value, $_SESSION['lang']);
}
$tpl->{$index} = $value;
}
ob_start();
try {
echo $tpl->execute();
} catch (Exception $e) {
echo $e;
}
$___phpBurnBufferStored = ob_get_contents();
//
// //Cleaning the buffer for new sessions
ob_clean();
return $___phpBurnBufferStored;
}
示例2: setTranslator
/**
* Sets the translator
*
* @param null $language
* @param string $domain
* @param string $translatorClass
*/
public function setTranslator($languages = ['en'], $domain = 'messages', $translatorClass = '\\PHPTAL_GetTextTranslator')
{
$translator = new $translatorClass($this);
$languages = !is_array($languages) ? [$languages] : $languages;
call_user_func_array([$translator, 'setLanguage'], $languages);
$translator->setEncoding($this->translationSettings['encoding']);
$translator->addDomain($domain);
$this->phptal->setTranslator($translator);
}
示例3: getTAL
/**
*
* @return PHPTAL
*/
protected function getTAL()
{
try {
if (!$this->TAL instanceof PHPTAL) {
$this->TAL = new PHPTAL($this->getPathTemplate());
}
$translator = new LBoxTranslator($this->getPathTemplate());
// zajistit existenci ciloveho adresare PHP kodu pro TAL:
$phptalPhpCodeDestination = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_PHP_CODE_DESTINATION"));
LBoxUtil::createDirByPath($phptalPhpCodeDestination);
$this->TAL->setTranslator($translator);
$this->TAL->setForceReparse(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_FORCE_REPARSE"));
$this->TAL->setPhpCodeDestination($phptalPhpCodeDestination);
$this->TAL->SELF = $this;
return $this->TAL;
} catch (Exception $e) {
throw $e;
}
}
示例4: display_tal
private function display_tal(midgardmvc_core_request $request, $content, array $data)
{
$tal = new PHPTAL($request->get_template_identifier());
$tal->setPhpCodeDestination($this->midgardmvc->cache->template->get_cache_directory());
$tal->uimessages = false;
if ($this->midgardmvc->configuration->enable_uimessages) {
if ($this->midgardmvc->uimessages->has_messages() && $this->midgardmvc->uimessages->can_view()) {
$tal->uimessages = $this->midgardmvc->uimessages->render();
}
}
$tal->midgardmvc = $this->midgardmvc;
$tal->request = $request;
// FIXME: Remove this once Qaiku has upgraded
$tal->MIDCOM = $this->midgardmvc;
foreach ($data as $key => $value) {
$tal->{$key} = $value;
}
$tal->setSource($content);
$translator =& $this->midgardmvc->i18n->set_translation_domain($request->get_component()->name);
$tal->setTranslator($translator);
try {
$content = $tal->execute();
} catch (PHPTAL_TemplateException $e) {
throw new midgardmvc_exception("PHPTAL: {$e->srcFile} line {$e->srcLine}: " . $e->getMessage());
}
return $content;
}
示例5: display_tal
private function display_tal($content, $data)
{
// We use the PHPTAL class
if (!class_exists('PHPTAL')) {
require 'PHPTAL.php';
}
// FIXME: Rethink whole tal modifiers concept
include_once 'TAL/modifiers.php';
$tal = new PHPTAL($this->get_cache_identifier());
$tal->uimessages = false;
if ($this->midgardmvc->configuration->enable_uimessages) {
if ($this->midgardmvc->uimessages->has_messages() && $this->midgardmvc->uimessages->can_view()) {
$tal->uimessages = $this->midgardmvc->uimessages->render();
}
}
$tal->midgardmvc = $this->midgardmvc;
// FIXME: Remove this once Qaiku has upgraded
$tal->MIDCOM = $this->midgardmvc;
foreach ($data as $key => $value) {
$tal->{$key} = $value;
}
$tal->setSource($content);
$translator =& $this->midgardmvc->i18n->set_translation_domain($this->midgardmvc->context->component);
$tal->setTranslator($translator);
try {
$content = $tal->execute();
} catch (PHPTAL_TemplateException $e) {
throw new midgardmvc_exception("PHPTAL: {$e->srcFile} line {$e->srcLine}: " . $e->getMessage());
}
return $content;
}