<commit_before><?php

/** Zend_Locale */
require_once 'Zend/Locale.php';

/** Zend_Translate_Adapter */
require_once 'Zend/Translate/Adapter.php';

require_once 'thirdparty/sfYaml/lib/sfYaml.php';

class Translate_Adapter_RailsYaml extends Zend_Translate_Adapter {

    /**
     * Generates the adapter
     *
     * @param  array|Zend_Config $options Translation content
     */
    public function __construct($options = array()) {
        $this->_options['keyDelimiter'] = ".";
        
        parent::__construct($options);
    }

    /**
     * Load translation data
     *
     * @param  string|array  $filename  Filename and full path to the translation source
     * @param  string        $locale    Locale/Language to add data for, identical with locale identifier,
     *                                  see Zend_Locale for more information
     * @param  array         $option    OPTIONAL Options to use
     */
    protected function _loadTranslationData($filename, $locale, array $options = array())
    {   
        $options = array_merge($this->_options, $options);

        if ($options['clear']  ||  !isset($this->_translate[$locale])) {
            $this->_translate[$locale] = array();
        }

        $this->_filename = $filename;
        if (!is_readable($this->_filename)) {
            require_once 'Zend/Translate/Exception.php';
            throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
        }

        $content = sfYaml::load(file_get_contents($this->_filename));
        if($locale != 'auto' && !array_key_exists($locale, $content)) {
            require_once 'Zend/Translate/Exception.php';
            throw new Zend_Translate_Exception(sprintf('Locale "%s" not found in file %s', $locale, $filename));
        }<commit_msg>ENHANCEMENT Added support for loading arrays in addition to file paths<commit_after><?php

/** Zend_Locale */
require_once 'Zend/Locale.php';

/** Zend_Translate_Adapter */
require_once 'Zend/Translate/Adapter.php';

require_once 'thirdparty/sfYaml/lib/sfYaml.php';

class Translate_Adapter_RailsYaml extends Zend_Translate_Adapter {

    /**
     * Generates the adapter
     *
     * @param  array|Zend_Config $options Translation content
     */
    public function __construct($options = array()) {
        $this->_options['keyDelimiter'] = ".";
        
        parent::__construct($options);
    }

    /**
     * Load translation data
     *
     * @param  string|array  $data  Filename and full path to the translation source
     * @param  string        $locale    Locale/Language to add data for, identical with locale identifier,
     *                                  see Zend_Locale for more information
     * @param  array         $option    OPTIONAL Options to use
     */
    protected function _loadTranslationData($data, $locale, array $options = array())
    {   
        $options = array_merge($this->_options, $options);

        if ($options['clear']  ||  !isset($this->_translate[$locale])) {
            $this->_translate[$locale] = array();
        }

        if(is_array($data)) return array($locale => $data);

        $this->_filename = $data;
        if (!is_readable($this->_filename)) {
            require_once 'Zend/Translate/Exception.php';
            throw new Zend_Translate_Exception('Error opening translation file \'' . $this->_filename . '\'.');
        }

        $content = sfYaml::load(file_get_contents($this->_filename));
        if($locale != 'auto' && !array_key_exists($locale, $content)) {
            require_once 'Zend/Translate/Exception.php';
            throw new Zend_Translate_Exception(sprintf('Locale "%s" not found in file %s', $locale, $this->_filename));
        }
{'fraction_non_alphanumeric': 0.12740899357601712, 'fraction_numerical': 0.0, 'mean_word_length': 2.6387536514118795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4655258', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1022, 'n_words': 238}