/**
  * определяет локаль пользователя, открывшего контроллер
  *
  * @return string код локали
  */
 protected function _get_locale()
 {
     // Первая попытка
     //      $zlocale = new Zend_Locale();
     //      $locale = $zlocale->toString();
     if (Plugin_Manager::isPlugin('locales')) {
         $this->load->helper('cookie');
         $locale = get_cookie(Plugin_Locales::$cookie_name);
         $exists = FALSE;
         // если есть куки
         if ('' != $locale) {
             $this->load->model('locales');
             if ($this->locales->isLocale($locale)) {
                 $exists = TRUE;
             }
             // если нет куки
             // попробуем определить из переменных окружения
         } else {
             if (isset($_ENV['LANG'])) {
                 if (preg_match('|[a-z]{2,4}_[a-z]{2,4}|i', $_ENV['LANG'], $matches)) {
                     $locale = $matches[0];
                     $this->load->model('locales');
                     if ($this->locales->isLocale($locale)) {
                         $exists = TRUE;
                     }
                 }
             }
         }
         if ($exists) {
             $this->locale = $locale;
             return $locale;
         }
     }
     // Вторая попытка
     // Дефолтное значение из settings
     if ($this->locale == "") {
         $this->locale = $this->global_variables->get("Locale", $this->user_id);
         if (is_null($this->locale)) {
             $this->locale = $this->global_variables->get("DefaultLocale");
         }
     }
     if (!defined('CRON')) {
         // Init global locale
         try {
             Zend_Registry::set('Zend_Locale', new Zend_Locale($this->locale));
         } catch (Sppc_Exception $e) {
             // Something wrong with locale initialization:
         }
     }
     return $this->locale;
 }