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


PHP Translator::loadCatalogue方法代码示例

本文整理汇总了PHP中Symfony\Component\Translation\Translator::loadCatalogue方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::loadCatalogue方法的具体用法?PHP Translator::loadCatalogue怎么用?PHP Translator::loadCatalogue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Translation\Translator的用法示例。


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

示例1: rebuildCache

    public function rebuildCache($locale)
    {
        $cache = new ConfigCache($this->options['cache_dir'] . '/catalogue.' . $locale . '.php', $this->options['debug']);
        $this->initialize();
        // one of the rare situations to "skip" to the grandparent implementation.
        \Symfony\Component\Translation\Translator::loadCatalogue($locale);
        $fallbackContent = '';
        $current = '';
        foreach ($this->computeFallbackLocales($locale) as $fallback) {
            $fallbackSuffix = ucfirst(str_replace('-', '_', $fallback));
            $fallbackContent .= sprintf(<<<EOF
\$catalogue%s = new MessageCatalogue('%s', %s);
\$catalogue%s->addFallbackCatalogue(\$catalogue%s);


EOF
, $fallbackSuffix, $fallback, var_export($this->catalogues[$fallback]->all(), true), ucfirst(str_replace('-', '_', $current)), $fallbackSuffix);
            $current = $fallback;
        }
        $content = sprintf(<<<EOF
<?php

use Symfony\\Component\\Translation\\MessageCatalogue;

\$catalogue = new MessageCatalogue('%s', %s);

%s
return \$catalogue;

EOF
, $locale, var_export($this->catalogues[$locale]->all(), true), $fallbackContent);
        $cache->write($content, $this->catalogues[$locale]->getResources());
    }
开发者ID:scottstuff,项目名称:GCProtractorJS,代码行数:33,代码来源:Translator.php

示例2: loadCatalogue

 /**
  * @{inheritDoc}
  */
 public function loadCatalogue($locale)
 {
     $cacheKey = sprintf('cog.localisation.translations1.%s', $locale);
     if (false === $this->_cacheEnabled or false === ($this->catalogues = $this->_container['cache']->fetch($cacheKey))) {
         $parser = $this->_container['reference_parser'];
         // Load translation files from modules
         foreach ($this->_container['module.loader']->getModules() as $moduleName) {
             $moduleName = str_replace('\\', $parser::SEPARATOR, $moduleName);
             $dir = 'cog://@' . $moduleName . $parser::MODULE_SEPARATOR . 'translations';
             if (file_exists($dir)) {
                 foreach ($this->_container['filesystem.finder']->in($dir) as $file) {
                     $this->addResource('yml', $file->getPathname(), $file->getFilenameWithoutExtension());
                 }
             }
         }
         // Load application translation files
         $dir = $this->_container['app.loader']->getBaseDir() . 'translations';
         if (file_exists($dir)) {
             foreach ($this->_container['filesystem.finder']->in($dir) as $file) {
                 $this->addResource('yml', $file->getPathname(), $file->getFilenameWithoutExtension());
             }
         }
         parent::loadCatalogue($locale);
         $this->_container['cache']->store($cacheKey, $this->catalogues);
     }
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:29,代码来源:Translator.php

示例3: loadCatalogue

    /**
     * {@inheritdoc}
     */
    protected function loadCatalogue($locale)
    {
        if (isset($this->catalogues[$locale])) {
            return;
        }
        if (null === $this->options['cache_dir']) {
            $this->initialize();
            return parent::loadCatalogue($locale);
        }
        $this->assertValidLocale($locale);
        $cache = new ConfigCache($this->options['cache_dir'] . '/catalogue.' . $locale . '.php', $this->options['debug']);
        if (!$cache->isFresh()) {
            $this->initialize();
            parent::loadCatalogue($locale);
            $fallbackContent = '';
            $current = '';
            $replacementPattern = '/[^a-z0-9_]/i';
            foreach ($this->computeFallbackLocales($locale) as $fallback) {
                $fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback));
                $currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current));
                $fallbackContent .= sprintf(<<<EOF
\$catalogue%s = new MessageCatalogue('%s', %s);
\$catalogue%s->addFallbackCatalogue(\$catalogue%s);


EOF
, $fallbackSuffix, $fallback, var_export($this->catalogues[$fallback]->all(), true), $currentSuffix, $fallbackSuffix);
                $current = $fallback;
            }
            $content = sprintf(<<<EOF
<?php

use Symfony\\Component\\Translation\\MessageCatalogue;

\$catalogue = new MessageCatalogue('%s', %s);

%s
return \$catalogue;

EOF
, $locale, var_export($this->catalogues[$locale]->all(), true), $fallbackContent);
            $cache->write($content, $this->catalogues[$locale]->getResources());
            return;
        }
        $this->catalogues[$locale] = (include $cache);
    }
开发者ID:rolfmadsen,项目名称:dummy_alma,代码行数:49,代码来源:Translator.php

示例4: loadCatalogue

 /**
  * {@inheritdoc}
  */
 protected function loadCatalogue($locale)
 {
     if (isset($this->catalogues[$locale])) {
         return;
     }
     if (null === $this->options['cache_dir']) {
         $this->initialize();
         return parent::loadCatalogue($locale);
     }
     if ($this->needsReload($locale)) {
         $this->initialize();
         parent::loadCatalogue($locale);
         $this->updateCache($locale);
         return;
     }
     $this->catalogues[$locale] = (include $this->getCacheFile($locale));
 }
开发者ID:notbrain,项目名称:symfony,代码行数:20,代码来源:Translator.php

示例5: loadCatalogue

 /**
  * {@inheritdoc}
  */
 protected function loadCatalogue($locale)
 {
     if (isset($this->catalogues[$locale])) {
         return;
     }
     if (null === $this->options['cache_dir']) {
         $this->initialize();
         return parent::loadCatalogue($locale);
     }
     $cache = new ConfigCache($this->options['cache_dir'] . '/catalogue.' . $locale . '.php', $this->options['debug']);
     if (!$cache->isFresh()) {
         $this->initialize();
         parent::loadCatalogue($locale);
         $content = sprintf("<?php use Symfony\\Component\\Translation\\MessageCatalogue; return new MessageCatalogue('%s', %s);", $locale, var_export($this->catalogues[$locale]->all(), true));
         $cache->write($content, $this->catalogues[$locale]->getResources());
         return;
     }
     $this->catalogues[$locale] = (include $cache);
 }
开发者ID:nightchiller,项目名称:symfony,代码行数:22,代码来源:Translator.php

示例6: loadCatalogue

    /**
     * {@inheritdoc}
     */
    protected function loadCatalogue($locale)
    {
        if (isset($this->catalogues[$locale])) {
            return;
        }
        if (null === $this->options['cache_dir']) {
            $this->initialize();
            return parent::loadCatalogue($locale);
        }
        $cache = new ConfigCache($this->options['cache_dir'] . '/catalogue.' . $locale . '.php', $this->options['debug']);
        if (!$cache->isFresh()) {
            $this->initialize();
            parent::loadCatalogue($locale);
            $fallbackContent = '';
            $fallback = $this->computeFallbackLocale($locale);
            if ($fallback && $fallback != $locale) {
                $fallbackContent = sprintf(<<<EOF
\$catalogue->addFallbackCatalogue(new MessageCatalogue('%s', %s));
EOF
, $fallback, var_export($this->catalogues[$fallback]->all(), true));
            }
            $content = sprintf(<<<EOF
<?php

use Symfony\\Component\\Translation\\MessageCatalogue;

\$catalogue = new MessageCatalogue('%s', %s);

%s

return \$catalogue;

EOF
, $locale, var_export($this->catalogues[$locale]->all(), true), $fallbackContent);
            $cache->write($content, $this->catalogues[$locale]->getResources());
            return;
        }
        $this->catalogues[$locale] = (include $cache);
    }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:42,代码来源:Translator.php


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