Example #1
2
 function MY_Language()
 {
     parent::CI_Language();
     global $CFG;
     global $URI;
     global $RTR;
     $segment = $URI->segment(1);
     if (isset($this->languages[$segment])) {
         $language = $this->languages[$segment];
         $CFG->set_item('language', $language);
         if ($RTR->scaffolding_request === TRUE) {
             // hide language segment for scaffolding code
             $RTR->uri->segments = $RTR->uri->rsegments;
         }
     } 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;
         }
     }
 }
 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_multi($langfile);
     }
     $deft_lang = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module || ($_module = CI::$APP->router->fetch_module());
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', $idiom);
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang';
             unset($lang);
         }
     }
     return $this->language;
 }
 /**
  * Display an error message
  *
  * @access	public
  * @param	string	the error message
  * @param	string	any "swap" values
  * @param	boolean	whether to localize the message
  * @return	string	sends the application/error_db.php template		
  */
 function display_error($error = '', $swap = '', $native = FALSE)
 {
     $LANG = new CI_Language();
     $LANG->load('db');
     $heading = 'MySQL Error';
     if ($native == TRUE) {
         $message = $error;
     } else {
         $message = !is_array($error) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
     }
     if (!class_exists('CI_Exceptions')) {
         include BASEPATH . 'libraries/Exceptions' . EXT;
     }
     $error = new CI_Exceptions();
     echo $error->show_error('An Error Was Encountered', $message, 'error_db');
     exit;
 }
Example #4
0
 public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
 {
     if (is_array($langfile)) {
         return $this->load_multi($langfile);
     }
     $deft_lang = MY_Loader::$APP->config->item('language');
     $idiom = $lang == '' ? $deft_lang : $lang;
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     $_module || ($_module = MY_Loader::$APP->router->fetch_module());
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', $idiom);
     // Falls back to a default language if the current language file is missing.
     if ($path === FALSE && self::$fall_back) {
         list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', self::$fall_back);
     }
     if ($path === FALSE) {
         if ($lang = parent::load($langfile, $lang, $return)) {
             return $lang;
         }
     } else {
         if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
             if ($return) {
                 return $lang;
             }
             $this->language = array_merge($this->language, $lang);
             $this->is_loaded[] = $langfile . '_lang' . EXT;
             unset($lang);
         }
     }
     return $this->language;
 }
 function MY_Language()
 {
     parent::CI_Language();
 }