Esempio n. 1
0
 function MY_Lang()
 {
     parent::__construct();
     global $CFG;
     global $URI;
     global $RTR;
     $this->uri = $URI->uri_string();
     $this->default_uri = $RTR->default_controller;
     $uri_segment = $this->get_uri_lang($this->uri);
     $this->lang_code = $uri_segment['lang'];
     $url_ok = false;
     if (!empty($this->lang_code) && array_key_exists($this->lang_code, $this->languages)) {
         $language = $this->languages[$this->lang_code];
         $CFG->set_item('language', $language);
         $url_ok = true;
     }
     if (!$url_ok && !$this->is_special($uri_segment['parts'][0])) {
         // set default language
         $CFG->set_item('language', $this->languages[$this->default_lang()]);
         $uri = !empty($this->uri) ? $this->uri : $this->default_uri;
         //OPB - modification to use i18n also without changing the .htaccess (without pretty url)
         $index_url = empty($CFG->config['index_page']) ? '' : $CFG->config['index_page'] . "/";
         $new_url = $CFG->config['base_url'] . $index_url . $this->default_lang() . '/' . $uri;
         header("Location: " . $new_url, TRUE, 302);
         exit;
     } else {
         if (array_key_exists($this->uri, $this->languages)) {
             $uri = $this->default_uri;
             $index_url = empty($CFG->config['index_page']) ? '' : $CFG->config['index_page'] . "/";
             $new_url = $CFG->config['base_url'] . $index_url . $this->lang_code . '/' . $uri;
             header("Location: " . $new_url, TRUE, 302);
         }
     }
 }
Esempio n. 2
0
 /**
  * The constructor initialize the library
  *
  * @return MY_Lang
  */
 function __construct()
 {
     parent::__construct();
     if (!extension_loaded('gettext')) {
         include_once 'gettext/gettext.inc';
         $_SESSION['GETTEXT_EXIST'] = FALSE;
     } else {
         $_SESSION['GETTEXT_EXIST'] = TRUE;
     }
 }
Esempio n. 3
0
 function __construct()
 {
     parent::__construct();
     $this->languages = json_decode(file_get_contents(APPPATH . 'language/lang.json'), true);
     global $CFG;
     global $URI;
     global $RTR;
     $segment = $URI->segment(1);
     if (isset($this->languages[$segment])) {
         $language = $this->languages[$segment];
         $CFG->set_item('language', $language);
     } else {
         if ($this->is_special($segment)) {
             return;
         } else {
             // set default language
             $CFG->set_item('language', $this->languages[$this->default_lang()]);
             // redirect
             header("Location: " . $CFG->site_url($this->localized($this->default_uri)), TRUE, 302);
             exit;
         }
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     $this->config = load_class('Config', 'core');
 }
 public function __construct()
 {
     parent::__construct();
 }
Esempio n. 6
0
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     log_message('debug', "IGO_Lang: Language Class Initialized");
 }