CI framework-lang.php of core files (load language packs)

Source: Internet
Author: User

<?phpif( !defined(' BasePath '))Exit(' No Direct script access allowed ');classCi_lang {var $language=Array(); var $is _loaded=Array(); function__construct () {Log_message (' Debug ', ' Language Class Initialized '); }    //Load Language Packs    functionLoad$langfile= ",$idiom= ",$return=FALSE,$add _suffix=TRUE,$alt _path= ' ')    {        $langfile=Str_replace('. php ', ',$langfile); if($add _suffix==TRUE)        {            $langfile=Str_replace(' _lang. ', ',$langfile).‘ _lang '; }        $langfile. = '. php '; if(In_array($langfile,$this->is_loaded,TRUE))        {            return; }        $config=&Get_config (); if($idiom= = "')        {            $deft _lang= ( !isset($config[' language '])) ? ' 中文版 ':$config[' Language ']; $idiom= ($deft _lang= = ')? ' 中文版 ':$deft _lang; }        //determine where the language file is and load it        if($alt _path! = ' &&file_exists($alt _path.‘ language/'.$idiom.‘ /‘.$langfile))        {            include($alt _path.‘ language/'.$idiom.‘ /‘.$langfile); }        Else        {            $found=FALSE; foreach(Get_instance ()->load->get_package_paths (TRUE) as $package _path)            {                if(file_exists($package _path.‘ language/'.$idiom.‘ /‘.$langfile))                {                    include($package _path.‘ language/'.$idiom.‘ /‘.$langfile); $found=TRUE;  Break; }            }            if($found!==TRUE) {Show_error (' Unable to load the requested language file:language/'.$idiom.‘ /‘.$langfile); }        }        if( !isset($lang) {log_message (' Error ', ' Language file contains no data:language/'.$idiom.‘ /‘.$langfile); return; }        if($return==TRUE)        {            return $lang; }        $this->is_loaded[] =$langfile; $this->language =Array_merge($this->language,$lang); unset($lang); Log_message (' Debug ', ' Language file loaded:language/'.$idiom.‘ /‘.$langfile); return TRUE; }    //remove a piece of data from the language array    functionLine$line= ' ')    {        $value= ($line= = ' OR!isset($this->language[$line])) ?FALSE:$this->language[$line]; //Because killer robots like unicorns!        if($value===FALSE) {log_message (' Error ', ' Could not find the language line '.$line.‘"‘); }        return $value; }}

CI framework-lang.php of core files (load language packs)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.