<commit_before><?php
/**
 * Extensions Locales Controller
 *
 * PHP version 5
 *
 * @category Controller
 * @package  Croogo
 * @version  1.0
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class ExtensionsLocalesController extends AppController {
/**
 * Controller name
 *
 * @var string
 * @access public
 */
    public $name = 'ExtensionsLocales';
/**
 * Models used by the Controller
 *
 * @var array
 * @access public
 */
    public $uses = array('Setting', 'User');

    public function beforeFilter() {
        parent::beforeFilter();
        App::import('Core', 'File');
        APP::import('Core', 'Folder');
    }

    public function admin_index() {
        $this->set('title_for_layout', __('Locales', true));

        $folder =& new Folder;
        $folder->path = APP . 'locale';
        $content = $folder->read();
        $locales = $content['0'];
        foreach($locales as $i => $locale) {
            if (strstr($locale, '.') !== false) {
                unset($locales[$i]);
            }
        }
        $this->set(compact('content', 'locales'));
    }

    public function admin_activate($locale = null) {
        if ($locale == null || !is_dir(APP . 'locale' . DS . $locale)) {
            $this->Session->setFlash(__('Locale does not exist.', true), 'default', array('class' => 'error'));
            $this->redirect(array('action' => 'index'));
        }
        if (!isset($this->params['named']['token']) || ($this->params['named']['token'] != $this->params['_Token']['key'])) {
            $blackHoleCallback = $this->Security->blackHoleCallback;
            $this->$blackHoleCallback();
        }

        $file =& new File(APP . 'config' . DS . 'croogo_bootstrap.php', true);
        $content = $file->read();

        $content = str_replace("Configure::write('Config.language', '" . Configure::read('Site.locale') . "');",
            "Configure::write('Config.language', '" . $locale . "');", $content);
        if ($file->write($content)) {
            $this->Setting->write('Site.locale', $locale);
            $this->Session->setFlash(__("Locale '{$locale}' set as default", true), 'default', array('class' => 'success'));
        } else {
            $this->Session->setFlash(__('Could not edit croogo_bootstrap.php file.', true), 'default', array('class' => 'error'));
        }
        $this->redirect(array('action' => 'index'));
    }

    public function admin_add() {
        $this->set('title_for_layout', __('Upload a new locale', true));

        if (!empty($this->data)) {
            $file = $this->data['Locale']['file'];
            unset($this->data['Locale']['file']);

            // get locale name
            $zip = zip_open($file['tmp_name']);
            $locale = null;<commit_msg>Changed line 70 to make it translatable<commit_after><?php
/**
 * Extensions Locales Controller
 *
 * PHP version 5
 *
 * @category Controller
 * @package  Croogo
 * @version  1.0
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class ExtensionsLocalesController extends AppController {
/**
 * Controller name
 *
 * @var string
 * @access public
 */
    public $name = 'ExtensionsLocales';
/**
 * Models used by the Controller
 *
 * @var array
 * @access public
 */
    public $uses = array('Setting', 'User');

    public function beforeFilter() {
        parent::beforeFilter();
        App::import('Core', 'File');
        APP::import('Core', 'Folder');
    }

    public function admin_index() {
        $this->set('title_for_layout', __('Locales', true));

        $folder =& new Folder;
        $folder->path = APP . 'locale';
        $content = $folder->read();
        $locales = $content['0'];
        foreach($locales as $i => $locale) {
            if (strstr($locale, '.') !== false) {
                unset($locales[$i]);
            }
        }
        $this->set(compact('content', 'locales'));
    }

    public function admin_activate($locale = null) {
        if ($locale == null || !is_dir(APP . 'locale' . DS . $locale)) {
            $this->Session->setFlash(__('Locale does not exist.', true), 'default', array('class' => 'error'));
            $this->redirect(array('action' => 'index'));
        }
        if (!isset($this->params['named']['token']) || ($this->params['named']['token'] != $this->params['_Token']['key'])) {
            $blackHoleCallback = $this->Security->blackHoleCallback;
            $this->$blackHoleCallback();
        }

        $file =& new File(APP . 'config' . DS . 'croogo_bootstrap.php', true);
        $content = $file->read();

        $content = str_replace("Configure::write('Config.language', '" . Configure::read('Site.locale') . "');",
            "Configure::write('Config.language', '" . $locale . "');", $content);
        if ($file->write($content)) {
            $this->Setting->write('Site.locale', $locale);
            $this->Session->setFlash(sprintf(__("Locale '%s' set as default", true), $locale), 'default', array('class' => 'success'));
        } else {
            $this->Session->setFlash(__('Could not edit croogo_bootstrap.php file.', true), 'default', array('class' => 'error'));
        }
        $this->redirect(array('action' => 'index'));
    }

    public function admin_add() {
        $this->set('title_for_layout', __('Upload a new locale', true));

        if (!empty($this->data)) {
            $file = $this->data['Locale']['file'];
            unset($this->data['Locale']['file']);

            // get locale name
            $zip = zip_open($file['tmp_name']);
            $locale = null;
{'fraction_non_alphanumeric': 0.19814782456753452, 'fraction_numerical': 0.0017473353136466887, 'mean_word_length': 2.6136363636363638, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2014374', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1641, 'n_words': 350}