Symfony\Component\Translation\Translator::loadCatalogue PHP Метод

loadCatalogue() защищенный Метод

protected loadCatalogue ( $locale )
    protected function loadCatalogue($locale)
    {
        $this->catalogues[$locale] = new MessageCatalogue($locale);

        if (isset($this->resources[$locale])) {
            foreach ($this->resources[$locale] as $resource) {
                if (!isset($this->loaders[$resource[0]])) {
                    throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
                }
                $this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
            }
        }

        $this->optimizeCatalogue($locale);
    }

Usage Example

Пример #1
0
    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());
    }
All Usage Examples Of Symfony\Component\Translation\Translator::loadCatalogue