<commit_before><?php

    namespace neoform\locale;

    class instance {

        /**
         * @var bool is the locale translation system active
         */
        protected $active = false;

        /**
         * @var array all iso2's allowed
         */
        protected $all_iso2;

        /**
         * @var string locale iso2
         */
        protected $default_iso2;

        /**
         * @var string locale iso2
         */
        protected $current_iso2;

        /**
         * @var integer
         */
        protected $namespace_id;

        /**
         * @var array id translation (name to id)
         */
        protected $namespace_ids = [];

        /**
         * @var array translations
         */
        protected $messages;

        /**
         * @var string base URL used to identify this locale
         */
        protected $struct;

        /**
         * @var array translated URL structs
         */
        protected $routes;

        /**
         * @param array $config
         */
        public function __construct(array $config) {
            $this->active       = (bool) $config['active'];
            $this->all_iso2     = array_merge([], $config['allowed']);
            $this->default_iso2 = (string) $config['default'];
            $this->set((string) $config['default']);
        }

        /**
         * Get current locale iso2
         *
         * @return mixed
         */
        public function get() {
            return $this->current_iso2;
        }

        /**
         * Get default locale iso2
         *
         * @return mixed
         */
        public function get_default() {
            return $this->default_iso2;
        }

        /**
         * All available locales
         *
         * @return array
         */
        public function all() {
            return $this->all_iso2;
        }

        /**
         * Set the current locale
         *
         * @param $iso2
         */
        public function set($iso2) {

            if (! $this->active) {
                return;
            }

            $this->current_iso2 = $iso2;
            $this->struct       = $iso2 === $this->default_iso2 ? '' : "/{$iso2}";
        }

        /**
         * Set the current namespace by name
         *
         * @param string $namespace_name
         */
        public function set_namespace($namespace_name) {

            if (! $this->active) {
                return;
            }

            if (! isset($this->namespace_ids[$namespace_name])) {
                $this->namespace_ids[$namespace_name] = (int) current(\neoform\entity::dao('locale\nspace')->by_name(
                    $namespace_name
                ));
            }

            $this->namespace_id = $this->namespace_ids[$namespace_name];

            if (! isset($this->messages[$this->namespace_id])) {
                $this->_load_translations($this->namespace_id);<commit_msg>PN-2 Fixed bug that caused route map to fail to load when locale is disabled.<commit_after><?php

    namespace neoform\locale;

    class instance {

        /**
         * @var bool is the locale translation system active
         */
        protected $active = false;

        /**
         * @var array all iso2's allowed
         */
        protected $all_iso2;

        /**
         * @var string locale iso2
         */
        protected $default_iso2;

        /**
         * @var string locale iso2
         */
        protected $current_iso2;

        /**
         * @var integer
         */
        protected $namespace_id;

        /**
         * @var array id translation (name to id)
         */
        protected $namespace_ids = [];

        /**
         * @var array translations
         */
        protected $messages;

        /**
         * @var string base URL used to identify this locale
         */
        protected $struct;

        /**
         * @var array translated URL structs
         */
        protected $routes;

        /**
         * @param array $config
         */
        public function __construct(array $config) {
            $this->active       = (bool) $config['active'];
            $this->all_iso2     = array_merge([], $config['allowed']);
            $this->default_iso2 = (string) $config['default'];
            $this->set((string) $config['default']);
        }

        /**
         * Get current locale iso2
         *
         * @return mixed
         */
        public function get() {
            return $this->current_iso2;
        }

        /**
         * Get default locale iso2
         *
         * @return mixed
         */
        public function get_default() {
            return $this->default_iso2;
        }

        /**
         * All available locales
         *
         * @return array
         */
        public function all() {
            return $this->all_iso2;
        }

        /**
         * Set the current locale
         *
         * @param $iso2
         */
        public function set($iso2) {
            $this->current_iso2 = $iso2;
            $this->struct       = $iso2 === $this->default_iso2 ? '' : "/{$iso2}";
        }

        /**
         * Set the current namespace by name
         *
         * @param string $namespace_name
         */
        public function set_namespace($namespace_name) {

            if (! $this->active) {
                return;
            }

            if (! isset($this->namespace_ids[$namespace_name])) {
                $this->namespace_ids[$namespace_name] = (int) current(\neoform\entity::dao('locale\nspace')->by_name(
                    $namespace_name
                ));
            }

            $this->namespace_id = $this->namespace_ids[$namespace_name];

            if (! isset($this->messages[$this->namespace_id])) {
                $this->_load_translations($this->namespace_id);
{'fraction_non_alphanumeric': 0.12161009721985332, 'fraction_numerical': 0.006993006993006993, 'mean_word_length': 1.2763975155279503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '4494557', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1485, 'n_words': 340}