Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
41
PHPTAL/Php/Attribute/I18N/Domain.php
Normal file
41
PHPTAL/Php/Attribute/I18N/Domain.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
require_once PHPTAL_DIR.'PHPTAL/Php/Attribute.php';
|
||||
|
||||
// i18n:domain
|
||||
//
|
||||
// The i18n:domain attribute is used to specify the domain to be used to get
|
||||
// the translation. If not specified, the translation services will use a
|
||||
// default domain. The value of the attribute is used directly; it is not
|
||||
// a TALES expression.
|
||||
//
|
||||
|
||||
/**
|
||||
* @package phptal.php.attribute.i18n
|
||||
*/
|
||||
class PHPTAL_Php_Attribute_I18N_Domain extends PHPTAL_Php_Attribute
|
||||
{
|
||||
public function start()
|
||||
{
|
||||
// ensure a domain stack exists or create it
|
||||
$this->tag->generator->doIf('!isset($__i18n_domains)');
|
||||
$this->tag->generator->pushCode('$__i18n_domains = array()');
|
||||
$this->tag->generator->doEnd();
|
||||
|
||||
//\''.str_replace(array('\\',"'"),array('\\\\',"\\'"),$expression).'\'
|
||||
$expression = $this->tag->generator->interpolateTalesVarsInString($this->expression);
|
||||
|
||||
// push current domain and use new domain
|
||||
$code = '$__i18n_domains[] = $_translator->useDomain('.$expression.')';
|
||||
$this->tag->generator->pushCode($code);
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
// restore domain
|
||||
$code = '$_translator->useDomain(array_pop($__i18n_domains))';
|
||||
$this->tag->generator->pushCode($code);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue