<commit_before><?php

namespace Liip\TranslationBundle\Translation;

use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\MessageCatalogue;

/**
 * A translator that work over an intermediate storage
 *
 * This file is part of the LiipTranslationBundle. For more information concerning
 * the bundle, see the README.md file at the project root.
 *
 * @package Liip\TranslationBundle\Persistence
 * @version 0.0.1
 *
 * @license http://opensource.org/licenses/MIT MIT License
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2013, Liip, http://www.liip.ch
 */
class Translator extends BaseTranslator
{
    /**
     * Store all the classical resources to be able to import them in the storage
     * @var array
     */
    protected $standardResources = array();

    protected $initialized = false;

    /**
     * Override the addResource, so that we can keep tracking standard resources
     *  but we don't call the parent method as we don't want to use them anymore
     * @param string $format
     * @param mixed $resource
     * @param string $locale
     * @param null $domain
     */
    public function addResource($format, $resource, $locale, $domain = null)
    {
        $this->standardResources[] = array(
            'format'=>$format,
            'path'=>$resource,
            'locale'=>$locale,
            'domain'=> $domain === null ? 'messages' : $domain
        );
    }

    /**
     * Return the list of 'standard' resources
     * @return array
     */
    public function getStandardResources()
    {
        // Check validity
        foreach ($this->standardResources as $resource) {
            if (!file_exists($resource['path'])) {
                throw new \RuntimeException('Ressources list is outdated, please run a cache:clear to update it');
            }
        }
        return $this->standardResources;
    }


    /**
     * Return the full catalog of a given locale
     *
     * @param $locale
     * @return \Symfony\Component\Translation\MessageCatalogueInterface
     */
    public function getCatalogue($locale)
    {
        if (!isset($this->catalogues[$locale])) {
            $this->loadCatalogue($locale);
        }

        return $this->catalogues[$locale];
    }


    /**
     * Load a specific resource
     * @param $resource
     * @return MessageCatalogue
     * @throws \RuntimeException
     */<commit_msg>align to symfony 2.6+<commit_after><?php

namespace Liip\TranslationBundle\Translation;

use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\MessageCatalogue;

/**
 * A translator that work over an intermediate storage
 *
 * This file is part of the LiipTranslationBundle. For more information concerning
 * the bundle, see the README.md file at the project root.
 *
 * @package Liip\TranslationBundle\Persistence
 * @version 0.0.1
 *
 * @license http://opensource.org/licenses/MIT MIT License
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2013, Liip, http://www.liip.ch
 */
class Translator extends BaseTranslator
{
    /**
     * Store all the classical resources to be able to import them in the storage
     * @var array
     */
    protected $standardResources = array();

    protected $initialized = false;

    /**
     * Override the addResource, so that we can keep tracking standard resources
     *  but we don't call the parent method as we don't want to use them anymore
     * @param string $format
     * @param mixed $resource
     * @param string $locale
     * @param null $domain
     */
    public function addResource($format, $resource, $locale, $domain = null)
    {
        $this->standardResources[] = array(
            'format'=>$format,
            'path'=>$resource,
            'locale'=>$locale,
            'domain'=> $domain === null ? 'messages' : $domain
        );
    }

    /**
     * Return the list of 'standard' resources
     * @return array
     */
    public function getStandardResources()
    {
        // Check validity
        foreach ($this->standardResources as $resource) {
            if (!file_exists($resource['path'])) {
                throw new \RuntimeException('Ressources list is outdated, please run a cache:clear to update it');
            }
        }
        return $this->standardResources;
    }

    /**
     * {@inheritdoc}
     *
     * Necessary only for versions of symfony < 2.6
     */
    public function getCatalogue($locale = null)
    {
        if (null === $locale) {
            $locale = $this->getLocale();
        }

        if (!isset($this->catalogues[$locale])) {
            $this->loadCatalogue($locale);
        }

        return $this->catalogues[$locale];
    }

    /**
     * Load a specific resource
     * @param $resource
     * @return MessageCatalogue
     * @throws \RuntimeException
     */
{'fraction_non_alphanumeric': 0.11662726556343578, 'fraction_numerical': 0.0035460992907801418, 'mean_word_length': 2.530598052851182, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2942475', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1367, 'n_words': 421}