<commit_before><?php
/**
 * Переводчик
 * User: keltanas
 * Date: 10.09.2010
 * Time: 13:37:19
 * To change this template use File | Settings | File Templates.
 */
 
class translate {

    private $lang;
    private $dictionary;

    private static $instance;

    protected function __construct()
    {
    }

    function setLanguage( $lang = 'en' )
    {
        $this->lang = $lang;
        $dict_file  = ROOT.DS.'protected'.DS.'lang'.DS.$this->lang.'.php';
        if ( file_exists($dict_file) ) {
            $this->dictionary = include($dict_file);
        }
        else {
            throw new Exception('Dictionary for language '.$this->lang.' not found in file '.$dict_file);
        }        
    }

    /**
     * @static
     * @return translate
     */
    static function getInstance()
    {
        if ( is_null( self::$instance ) ) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    function write( $text )
    {
        if ( isset( $this->dictionary[$text] ) ) {
            return $this->dictionary[$text];
        }
        return $text;
    }
}<commit_msg>fix: доработка переводчика<commit_after><?php
/**
 * Переводчик
 */
 
class translate {

    private $lang;
    private $dictionary;

    private static $instance;

    protected function __construct()
    {
    }

    function setLanguage( $lang = 'en' )
    {
        $this->lang = $lang;
        $dict_file  = 'protected'.DS.'lang'.DS.$this->lang.'.php';
        if ( ! $this->dictionary = @include($dict_file) ) {
            throw new Exception('Dictionary for language '.$this->lang.' not found in file '.$dict_file);
        }        
    }

    /**
     * @static
     * @return translate
     */
    static function getInstance()
    { 
        if ( is_null( self::$instance ) ) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    function write( $text )
    {
        if ( isset( $this->dictionary[$text] ) ) {
            return $this->dictionary[$text];
        }
        return $text;
    }
}
{'fraction_non_alphanumeric': 0.14609450337512053, 'fraction_numerical': 0.006750241080038573, 'mean_word_length': 1.8541953232462174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3349944', 'n_tokens_mistral': 646, 'n_tokens_neox': 625, 'n_words': 139}