<commit_before><?php
App::import('Config','Tradutore.languages');

class TradLanguageSelectorComponent extends Object
{
	var $components = array('Session');
	var $Controller;
	
	
    function initialize(&$Controller)
    {
		$this->Controller =& $Controller;
		$main_language = Configure::read('Tradutore.mainLanguage');
		if (isset($Controller->params['language']))
			$lang = $Controller->params['language'];
		elseif (isset($Controller->params['named']['language']))
			$lang = $Controller->params['named']['language'];
		else
			$lang = '';

		if (!empty($lang))
		{
			$languages = Configure::read('Tradutore.languages');
			if (in_array($lang, $languages))
			{
				$this->setLanguage($lang);
				$this->Session->write('Tradutore.currentLanguage', $lang);
				return true;
			}
		}
		
		if (!$this->Session->check('Tradutore.currentLanguage'))
			$this->Session->write('Tradutore.currentLanguage', $main_language);

		$this->setLanguage($this->Session->read('Tradutore.currentLanguage'));
		$this->Controller->set('mainLanguage', $main_language);
	}
   
    function setLanguage($lang = null)
    {
        $this->setInterfaceLanguage($lang);
		$this->setModelLanguage($lang);
	
		$this->Controller->set('currentLanguage', $lang);
	}
	
	function setInterfaceLanguage($lang = null)
    {
        Configure::write('Config.language', $lang);
		
		$this->Controller->set('currentInterfaceLanguage', $lang);
	}
	
	
	function setModelLanguage($lang = null)
    {
		App::import('Behavior','Tradutore.TradTradutore');
        TradTradutoreBehavior::setGlobalLanguage($lang);
		
		$this->Controller->set('currentModelLanguage', $lang);
	}
}
?>
<commit_msg>Fixing an bug with TradLanguageSelector<commit_after><?php
App::import('Config','Tradutore.languages');

class TradLanguageSelectorComponent extends Object
{
	var $components = array('Session');
	var $Controller;
	
	
    function initialize(&$Controller)
    {
		$this->Controller =& $Controller;

		$main_language = Configure::read('Tradutore.mainLanguage');
		$this->Controller->set('mainLanguage', $main_language);

		if (isset($Controller->params['language']))
			$lang = $Controller->params['language'];
		elseif (isset($Controller->params['named']['language']))
			$lang = $Controller->params['named']['language'];
		else
			$lang = '';

		if (!empty($lang))
		{
			$languages = Configure::read('Tradutore.languages');
			if (in_array($lang, $languages))
			{
				$this->setLanguage($lang);
				$this->Session->write('Tradutore.currentLanguage', $lang);
				return true;
			}
		}
		
		if (!$this->Session->check('Tradutore.currentLanguage'))
			$this->Session->write('Tradutore.currentLanguage', $main_language);

		$this->setLanguage($this->Session->read('Tradutore.currentLanguage'));
	}
   
    function setLanguage($lang = null)
    {
        $this->setInterfaceLanguage($lang);
		$this->setModelLanguage($lang);
	
		$this->Controller->set('currentLanguage', $lang);
	}
	
	function setInterfaceLanguage($lang = null)
    {
        Configure::write('Config.language', $lang);
		
		$this->Controller->set('currentInterfaceLanguage', $lang);
	}
	
	
	function setModelLanguage($lang = null)
    {
		App::import('Behavior','Tradutore.TradTradutore');
        TradTradutoreBehavior::setGlobalLanguage($lang);
		
		$this->Controller->set('currentModelLanguage', $lang);
	}
}
?>

{'fraction_non_alphanumeric': 0.18236352729454108, 'fraction_numerical': 0.0, 'mean_word_length': 4.902654867256637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '6003201', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1020, 'n_words': 138}