MX_Lang::load PHP Method

load() public method

public load ( $langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '' )
    public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
    {
        if (is_array($langfile)) {
            foreach ($langfile as $_lang) {
                $this->load($_lang);
            }
            return $this->language;
        }
        $deft_lang = CI::$APP->config->item('language');
        $idiom = $lang == '' ? $deft_lang : $lang;
        if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
            return $this->language;
        }
        $_module or $_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, $add_suffix, $alt_path)) {
                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;
    }

Usage Example

Exemplo n.º 1
0
 public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
 {
     //	Are we loading an array of languages? If so, handle each one on its own.
     if (is_array($langfile)) {
         foreach ($langfile as $_lang) {
             $this->load($_lang);
         }
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Determine which language we're using, if not specified, use the app's default
     $_default = CI::$APP->config->item('language');
     $idiom = $lang == '' ? $_default : $lang;
     // --------------------------------------------------------------------------
     //	Check to see if the language file has already been loaded
     if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
         return $this->language;
     }
     // --------------------------------------------------------------------------
     //	Look for the language
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
     /**
      *
      * Confession. I'm not entirely sure how/why this works. Dumping out debug statements confuses
      * me as they don't make sense, but the right lang files seem to be laoded. Sorry, future Pablo.
      *
      **/
     if ($path === FALSE) {
         //	File not found, fallback to the default language if not already using it
         if ($idiom != $_default) {
             //	Using MXs version seems to work as expected.
             if ($lang = parent::load($langfile, $_default, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         } else {
             //	Not found within modules, try normal load()
             if ($lang = CI_Lang::load($langfile, $idiom, $return, $add_suffix, $alt_path)) {
                 return $lang;
             }
         }
     } else {
         //	Lang file was found. Load it.
         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;
 }
All Usage Examples Of MX_Lang::load
MX_Lang