当前位置: 首页>>代码示例>>PHP>>正文


PHP eZTranslatorManager类代码示例

本文整理汇总了PHP中eZTranslatorManager的典型用法代码示例。如果您正苦于以下问题:PHP eZTranslatorManager类的具体用法?PHP eZTranslatorManager怎么用?PHP eZTranslatorManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了eZTranslatorManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: eZCheckValidity

/**
 * Checks if the installation is valid and returns a module redirect if required.
 * If CheckValidity in SiteAccessSettings is false then no check is done.
 *
 * @deprecated As of 4.4, moved to index.php for now
 * @param array $siteBasics
 * @param eZURI $uri
 */
function eZCheckValidity( array &$siteBasics, eZURI $uri )
{
    eZDebug::writeStrict( 'Function eZCheckValidity() has been deprecated in 4.4', 'Deprecation' );
    $ini = eZINI::instance();
    $checkValidity = ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) == "true" );
    $check = null;
    if ( $checkValidity )
    {
        $check = array( "module" => "setup",
                        'function' => 'init' );
        // Turn off some features that won't bee needed yet
//        $siteBasics['policy-check-required'] = false;
        $siteBasics['policy-check-omit-list'][] = 'setup';
        $siteBasics['url-translator-allowed'] = false;
        $siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' );
        $siteBasics['validity-check-required'] = true;
        $siteBasics['user-object-required'] = false;
        $siteBasics['session-required'] = false;
        $siteBasics['db-required'] = false;
        $siteBasics['no-cache-adviced'] = false;
        $siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' );
        $access = array( 'name' => 'setup',
                         'type' => eZSiteAccess::TYPE_URI );
        $access = eZSiteAccess::change( $access );

        eZTranslatorManager::enableDynamicTranslations();
    }
    return $check;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:37,代码来源:pre_check.php

示例2: initialize

 static function initialize()
 {
     if (!isset($GLOBALS['eZ1337Translator']) || !$GLOBALS['eZ1337Translator'] instanceof eZ1337Translator) {
         $GLOBALS['eZ1337Translator'] = new eZ1337Translator();
     }
     $man = eZTranslatorManager::instance();
     $man->registerHandler($GLOBALS['eZ1337Translator']);
     return $GLOBALS['eZ1337Translator'];
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:9,代码来源:ez1337translator.php

示例3: display

 function display()
 {
     $result = array();
     $languages = false;
     $defaultLanguage = false;
     $defaultExtraLanguages = false;
     eZSetupLanguageList($languages, $defaultLanguage, $defaultExtraLanguages);
     eZTranslatorManager::setActiveTranslation($defaultLanguage, false);
     $this->Tpl->setVariable('language_list', $languages);
     $this->Tpl->setVariable('primary_language', $defaultLanguage);
     $this->Tpl->setVariable('optional_test', array('result' => $this->OptionalResult, 'results' => $this->OptionalResults));
     $result['content'] = $this->Tpl->fetch('design:setup/init/welcome.tpl');
     $result['path'] = array(array('text' => ezpI18n::tr('design/standard/setup/init', 'Welcome to eZ Publish'), 'url' => false));
     return $result;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:15,代码来源:ezstep_welcome.php

示例4: i18nTrans

 function i18nTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     // i18n( $input, $context, $comment, $arguments )
     // Check if if the three first parameters are constants, if not we cannot compile it
     foreach (array_slice($parameters, 0, 3) as $parameter) {
         if ($parameter !== null && !eZTemplateNodeTool::isConstantElement($parameter)) {
             return false;
         }
     }
     $value = eZTemplateNodeTool::elementConstantValue($parameters[0]);
     $numParameters = count($parameters);
     $context = $numParameters > 1 ? eZTemplateNodeTool::elementConstantValue($parameters[1]) : null;
     $comment = $numParameters > 2 ? eZTemplateNodeTool::elementConstantValue($parameters[2]) : null;
     if ($numParameters < 4) {
         return array(eZTemplateNodeTool::createStringElement(ezpI18n::tr($context, $value, $comment, null)));
     }
     $values = array();
     $ini = eZINI::instance();
     if ($ini->variable('RegionalSettings', 'TextTranslation') != 'disabled') {
         $language = eZLocale::instance()->localeFullCode();
         if ($language != "eng-GB") {
             $file = 'translation.ts';
             $ini = eZINI::instance();
             $useCache = $ini->variable('RegionalSettings', 'TranslationCache') != 'disabled';
             eZTSTranslator::initialize($context, $language, $file, $useCache);
             $man = eZTranslatorManager::instance();
             $newValue = $man->translate($context, $value, $comment);
             if ($newValue) {
                 $value = $newValue;
             }
         }
     }
     $values[] = array(eZTemplateNodeTool::createStringElement($value));
     $values[] = $parameters[3];
     $code = '%tmp1% = array();' . "\n" . 'foreach ( %2% as %tmp2% => %tmp3% )' . "\n" . '{' . "\n" . '  if ( is_int( %tmp2% ) )' . "\n" . '    %tmp1%[\'%\' . ( (%tmp2%%9) + 1 )] = %tmp3%;' . "\n" . '  else' . "\n" . '    %tmp1%[%tmp2%] = %tmp3%;' . "\n" . '}' . "\n" . '%output% = strtr( %1%, %tmp1% );' . "\n";
     return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 3));
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:37,代码来源:ezi18noperator.php

示例5: findMessage

 function findMessage( $context, $source, $comment = null )
 {
     $man = eZTranslatorManager::instance();
     $translation = $this->shuffleText( $source );
     return $man->createMessage( $context, $source, $comment, $translation );
 }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:6,代码来源:ezshuffletranslator.php

示例6: remove

 /**
  * Removes the translation message with context $context and source $source.
  *
  * If you have the translation key use removeKey() instead.
  *
  * @param string $context
  * @param string $source
  * @param string $message
  *
  * @return bool true if the message was removed, false otherwise
  */
 function remove($context, $source, $message = null)
 {
     if ($context == "") {
         $context = "default";
     }
     $man = eZTranslatorManager::instance();
     $key = $man->createKey($context, $source, $message);
     if (isset($this->Messages[$key])) {
         unset($this->Messages[$key]);
     }
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:22,代码来源:eztstranslator.php

示例7: translateText

 /**
  * Translates the source \a $source with context \a $context and optional comment \a $comment
  * and returns the translation if locale code is not eng-GB.
  * Uses {@link eZTranslatorMananger::translate()} to do the actual translation
  *
  * Example:
  * translateText( 'content/view', 'There are %count nodes in this list out of %total total nodes.', 'Children view of nodes for whole site', array( '%count' => $c, '%total' => $t ) );
  *
  * @param string $context
  * @param string $source
  * @param string|null $comment
  * @param array|null $arguments
  * @return string
  */
 protected static function translateText($context, $source, $comment = null, $arguments = null)
 {
     $localeCode = eZLocale::instance()->localeFullCode();
     if ($localeCode == 'eng-GB') {
         // we don't have ts-file for 'eng-GB'.
         return self::insertArguments($source, $arguments);
     }
     $ini = eZINI::instance();
     $useCache = $ini->variable('RegionalSettings', 'TranslationCache') != 'disabled';
     eZTSTranslator::initialize($context, $localeCode, 'translation.ts', $useCache);
     // Bork translation: Makes it easy to see what is not translated.
     // If no translation is found in the eZTSTranslator, a Bork translation will be returned.
     // Bork is different than, but similar to, eng-GB, and is enclosed in square brackets [].
     $developmentMode = $ini->variable('RegionalSettings', 'DevelopmentMode') != 'disabled';
     if ($developmentMode) {
         eZBorkTranslator::initialize();
     }
     $man = eZTranslatorManager::instance();
     $trans = $man->translate($context, $source, $comment);
     if ($trans !== null) {
         return self::insertArguments($trans, $arguments);
     }
     if ($comment != null and strlen($comment) > 0) {
         eZDebug::writeDebug("Missing translation for message in context: '{$context}' with comment: '{$comment}'. The untranslated message is: '{$source}'", __METHOD__);
     } else {
         eZDebug::writeDebug("Missing translation for message in context: '{$context}'. The untranslated message is: '{$source}'", __METHOD__);
     }
     return self::insertArguments($source, $arguments);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:43,代码来源:ezpi18n.php

示例8: requestInit

 protected function requestInit()
 {
     if ($this->isInitialized) {
         return;
     }
     eZExecution::setCleanExit(false);
     $scriptStartTime = microtime(true);
     $GLOBALS['eZRedirection'] = false;
     $this->access = eZSiteAccess::current();
     eZDebug::setScriptStart($scriptStartTime);
     eZDebug::addTimingPoint("Script start");
     $this->uri = eZURI::instance(eZSys::requestURI());
     $GLOBALS['eZRequestedURI'] = $this->uri;
     // Be able to do general events early in process
     ezpEvent::getInstance()->notify('request/preinput', array($this->uri));
     // Initialize module loading
     $this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
     eZModule::setGlobalPathList($this->siteBasics['module-repositories']);
     // make sure we get a new $ini instance now that it has been reset
     $ini = eZINI::instance();
     // start: eZCheckValidity
     // pre check, setup wizard related so needs to be before session/db init
     // TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
     if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') {
         $this->check = array('module' => 'setup', 'function' => 'init');
         // Turn off some features that won't bee needed yet
         $this->siteBasics['policy-check-omit-list'][] = 'setup';
         $this->siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout');
         $this->siteBasics['validity-check-required'] = true;
         $this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
         $this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
         $this->siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign');
         $this->access = eZSiteAccess::change(array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI));
         eZTranslatorManager::enableDynamicTranslations();
     }
     // stop: eZCheckValidity
     if ($this->siteBasics['session-required']) {
         // Check if this should be run in a cronjob
         if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') {
             eZSession::addCallback('destroy_pre', function (eZDBInterface $db, $key, $escapedKey) {
                 $basket = eZBasket::fetch($key);
                 if ($basket instanceof eZBasket) {
                     $basket->remove();
                 }
             });
             eZSession::addCallback('gc_pre', function (eZDBInterface $db, $time) {
                 eZBasket::cleanupExpired($time);
             });
             eZSession::addCallback('cleanup_pre', function (eZDBInterface $db) {
                 eZBasket::cleanup();
             });
         }
         // addCallBack to update session id for shop basket on session regenerate
         eZSession::addCallback('regenerate_post', function (eZDBInterface $db, $escNewKey, $escOldKey) {
             $db->query("UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'");
         });
         // TODO: Session starting should be made only once in the constructor
         $this->sessionInit();
     }
     // if $this->siteBasics['db-required'], open a db connection and check that db is connected
     if ($this->siteBasics['db-required'] && !eZDB::instance()->isConnected()) {
         $this->warningList[] = array('error' => array('type' => 'kernel', 'number' => eZError::KERNEL_NO_DB_CONNECTION), 'text' => 'No database connection could be made, the system might not behave properly.');
     }
     // eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
     if (!isset($this->check)) {
         $this->check = eZUserLoginHandler::preCheck($this->siteBasics, $this->uri);
     }
     ezpEvent::getInstance()->notify('request/input', array($this->uri));
     // Initialize with locale settings
     // TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
     $this->languageCode = eZLocale::instance()->httpLocaleCode();
     $phpLocale = trim($ini->variable('RegionalSettings', 'SystemLocale'));
     if ($phpLocale != '') {
         setlocale(LC_ALL, explode(',', $phpLocale));
     }
     $this->httpCharset = eZTextCodec::httpCharset();
     // TODO: are these parameters supposed to vary across potential sub-requests?
     $this->site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Content-language' => $this->languageCode));
     // Read role settings
     $this->siteBasics['policy-check-omit-list'] = array_merge($this->siteBasics['policy-check-omit-list'], $ini->variable('RoleSettings', 'PolicyOmitList'));
     $this->isInitialized = true;
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:82,代码来源:ezpkernelweb.php

示例9: setActiveTranslation

 static function setActiveTranslation($locale, $permanently = true)
 {
     if (!eZTranslatorManager::dynamicTranslationsEnabled()) {
         return;
     }
     if ($permanently) {
         $siteINI = eZINI::instance('site.ini.append', 'settings/override', null, null, false, true);
     } else {
         $siteINI = eZINI::instance();
     }
     $siteINI->setVariable('RegionalSettings', 'Locale', $locale);
     $siteINI->setVariable('RegionalSettings', 'TextTranslation', 'enabled');
     if ($permanently) {
         $siteINI->save('site.ini.append', '.php', false, false);
         eZINI::resetInstance("site.ini");
     }
     eZTranslatorManager::resetTranslations();
 }
开发者ID:legende91,项目名称:ez,代码行数:18,代码来源:eztranslatormanager.php

示例10: initialize

    static function initialize( $context, $locale, $useCache = true )
    {
        if ( !isset( $GLOBALS['eZBorkTranslator'] ) ||
             !( $GLOBALS['eZBorkTranslator'] instanceof eZBorkTranslator ) )
        {
            $GLOBALS['eZBorkTranslator'] = new eZBorkTranslator();
        }

        $man = eZTranslatorManager::instance();
        $man->registerHandler( $GLOBALS['eZBorkTranslator'] );
        return $GLOBALS['eZBorkTranslator'];
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:12,代码来源:ezborktranslator.php

示例11: array

    if ($contentINI->hasVariable('VersionView', 'DefaultPreviewDesign')) {
        $siteAccess = $contentINI->variable('VersionView', 'DefaultPreviewDesign');
    } else {
        $siteAccess = eZTemplateDesignResource::designSetting('site');
    }
}
$access = $GLOBALS['eZCurrentAccess'];
$access['name'] = $siteAccess;
if ($access['type'] === eZSiteAccess::TYPE_URI) {
    $access['uri_part'] = array($siteAccess);
}
eZSiteAccess::load($access);
eZDebug::checkDebugByUser();
// Change content object default language
$GLOBALS['eZContentObjectDefaultLanguage'] = $LanguageCode;
eZTranslatorManager::resetTranslations();
ezpI18n::reset();
eZContentObject::clearCache();
eZContentLanguage::expireCache();
$Module->setTitle('View ' . $class->attribute('name') . ' - ' . $contentObject->attribute('name'));
$ini = eZINI::instance();
$res = eZTemplateDesignResource::instance();
$res->setDesignSetting($ini->variable('DesignSettings', 'SiteDesign'), 'site');
$res->setOverrideAccess($siteAccess);
$tpl = eZTemplate::factory();
if ($http->hasSessionVariable('LastAccessesVersionURI')) {
    $tpl->setVariable('redirect_uri', $http->sessionVariable('LastAccessesVersionURI'));
}
$designKeys = array(array('object', $contentObject->attribute('id')), array('node', $virtualNodeID), array('remote_id', $contentObject->attribute('remote_id')), array('class', $class->attribute('id')), array('class_identifier', $class->attribute('identifier')), array('viewmode', 'full'));
// View mode
if ($assignment) {
开发者ID:schwabokaner,项目名称:ezpublish-legacy,代码行数:31,代码来源:versionview.php

示例12: array

// make sure we get a new $ini instance now that it has been reset
$ini = eZINI::instance();
// start: eZCheckValidity
// pre check, setup wizard related so needs to be before session/db init
if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') {
    $check = array('module' => 'setup', 'function' => 'init');
    // Turn off some features that won't bee needed yet
    $siteBasics['policy-check-omit-list'][] = 'setup';
    $siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout');
    $siteBasics['validity-check-required'] = true;
    $siteBasics['session-required'] = $siteBasics['user-object-required'] = false;
    $siteBasics['db-required'] = $siteBasics['no-cache-adviced'] = $siteBasics['url-translator-allowed'] = false;
    $siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign');
    $access = array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI);
    $access = eZSiteAccess::change($access);
    eZTranslatorManager::enableDynamicTranslations();
}
// stop: eZCheckValidity
if ($sessionRequired) {
    // Check if this should be run in a cronjob
    if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') {
        // Functions for session to make sure baskets are cleaned up
        function eZSessionBasketDestroy($db, $key, $escapedKey)
        {
            $basket = eZBasket::fetch($key);
            if (is_object($basket)) {
                $basket->remove();
            }
        }
        function eZSessionBasketGarbageCollector($db, $time)
        {
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:index.php

示例13: translateText

    /**
     * Translates the source \a $source with context \a $context and optional comment \a $comment
     * and returns the translation if locale code is not eng-GB.
     * Uses {@link eZTranslatorMananger::translate()} to do the actual translation
     *
     * Example:
     * translateText( 'content/view', 'There are %count nodes in this list out of %total total nodes.', 'Children view of nodes for whole site', array( '%count' => $c, '%total' => $t ) );
     *
     * @param string $context
     * @param string $source
     * @param string|null $comment
     * @param array|null $arguments
     * @return string
     */
    protected static function translateText( $context, $source, $comment = null, $arguments = null )
    {
        $localeCode = eZLocale::instance()->localeFullCode();
        if ( $localeCode == 'eng-GB' )
        {
            // we don't have ts-file for 'eng-GB'.
            return self::insertArguments( $source, $arguments );
        }

        // Load all TranslatorHandlers from settings
        $ini = eZINI::instance();
        $useCache = $ini->variable( 'RegionalSettings', 'TranslationCache' ) != 'disabled';
        $handlerClassList = $ini->variable( 'RegionalSettings', 'TranslatorHandlers' );
        foreach( $handlerClassList as $handlerClass )
        {
            call_user_func_array( array( $handlerClass, 'initialize' ), array( $context, $localeCode, $useCache ) );
        }

        // Bork translation: Makes it easy to see what is not translated.
        // If no translation is found in the eZTSTranslator, a Bork translation will be returned.
        // Bork is different than, but similar to, eng-GB, and is enclosed in square brackets [].
        $developmentMode = $ini->variable( 'RegionalSettings', 'DevelopmentMode' ) != 'disabled';
        if ( $developmentMode && ! in_array( 'eZBorkTranslator', $handlerClassList ) )
        {
            eZBorkTranslator::initialize( $context, $localeCode, $useCache );
        }

        $man = eZTranslatorManager::instance();
        $trans = $man->translate( $context, $source, $comment );
        if ( $trans !== null ) {
            return self::insertArguments( $trans, $arguments );
        }

        if ( $comment != null and strlen( $comment ) > 0 )
            eZDebug::writeDebug( "Missing translation for message in context: '$context' with comment: '$comment'. The untranslated message is: '$source'", __METHOD__ );
        else
            eZDebug::writeDebug( "Missing translation for message in context: '$context'. The untranslated message is: '$source'", __METHOD__ );

        return self::insertArguments( $source, $arguments );
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:54,代码来源:ezpi18n.php


注:本文中的eZTranslatorManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。