[Php] <? Php if (! Defined ('basepath') exit ('no direct script access allowed '); /*** CodeIgniter ** An open source application development framework for PHP 5.1.6 or newer ** @ package CodeIgniter * @ author ExpressionEngine Dev Team * @ copyright Copyright (c) 2008-2011, ellisLab, Inc. * @ license http://codeigniter.com/user_guide/license.html * @ link http://codeigniter.com * @ since Version 1.0 * @ filesource *// /------------------------------------------------------------------------/*** Language Class * Official User Manual: http://codeigniter.org.cn/user_guide/libraries/language.html * @ package CodeIgniter * @ subpackage Libraries * @ category Language * @ author ExpressionEngine Dev Team * @ link http://codeigniter.com/user_guide/libraries/language.html */class CI_Lang {/*** List of translations * Language Pack List *@ var arr Ay */var $ language = array (); /*** List of loaded language files * List of language packs loaded * @ var array */var $ is_loaded = array (); /*** Constructor *** @ access public */function _ construct () {log_message ('debug', "Language Class Initialized ");} // ----------------------------------------------------------------------/*** Load a language file * Load language Pack * @ access public * @ param mixed the name of the lan Guage file to be loaded. Can be an array * language file to be loaded. * @ Param string the language (english, etc .) the language to use * @ param bool return loaded array of translations directly returns the language Pack array * not added to $ this-> is_loaded and $ this-> language * @ param bool add suffix to $ langfile whether to add the suffix * @ param string alternative path to look for language file custom path * @ return mixed */function load ($ langfile = '', $ idiom = '', $ return = FALSE, $ add_suffix = TRUE, $ alt_path ='') {// langfile File. remove the php suffix $ langfile = str_replace ('. php ', '', $ langfile); // you do not need to add a suffix if you need it. // SET _ lang. remove and add _ lang if ($ add_suffix = TRUE) {$ langfile = str_replace ('_ lang. ', '', $ langfile ). '_ lang';} // Add a name for langfile. php suffix $ langfile. = '. php '; // determine whether the current file has been loaded if (in_array ($ langfile, $ this-> is_loaded, TRUE) {return ;} // get the data in the configuration file $ config = & get_config (); // if the language to be used is null // we will get if ($ idio M = '') {$ deft_lang = (! Isset ($ config ['language'])? 'Inc': $ config ['language']; $ idiom = ($ deft_lang = '')? 'Inc': $ deft_lang;} // Determine where the language file is and load it // find the language Pack in the custom path and load if ($ alt_path! = ''& File_exists ($ alt_path. 'language /'. $ idiom. '/'. $ langfile) {include ($ alt_path. 'language /'. $ idiom. '/'. $ langfile);} else {// call get_instance ()-> load-> get_package_paths (TRUE) if the custom path is not found) // search for/get_package_paths in the package path. in php, $ found = FALSE; foreach (get_instance ()-> load-> get_package_paths (TRUE) as $ package_path) {if (file_exists ($ package_path. 'language /'. $ idiom. '/'. $ langfile) {incl Ude ($ package_path. 'language /'. $ idiom. '/'. $ langfile); $ found = TRUE; break;} // if not found, only an error is returned. // 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 ;}//-------------------------------------------------- ------------------/*** Fetch a single line of text from the language array * get a line of text * @ access public * @ param string $ line the language line * @ return string */function line ($ line = '') {/** $ this-> language format * $ lang ['error _ email_missing '] = "You must submit an email address "; * $ lang ['error _ url_missing '] = "You must submit a URL"; * $ lang ['error _ username_missing'] = "You must submit a user Name "; */$ 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 ;}// END Language Class/* End of file Lang. php * // * Location :. /system/core/Lang. php */