Language.php
Go to the documentation of this file.00001 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class CI_Language {
00028
00029 var $language = array();
00030 var $is_loaded = array();
00031
00032
00033
00034
00035
00036
00037 function CI_Language()
00038 {
00039 log_message('debug', "Language Class Initialized");
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 function load($langfile = '', $idiom = '', $return = FALSE)
00053 {
00054 $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
00055
00056 if (in_array($langfile, $this->is_loaded, TRUE))
00057 {
00058 return;
00059 }
00060
00061 if ($idiom == '')
00062 {
00063 $CI =& get_instance();
00064 $deft_lang = $CI->config->item('language');
00065 $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
00066 }
00067
00068
00069 if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
00070 {
00071 include(APPPATH.'language/'.$idiom.'/'.$langfile);
00072 }
00073 else
00074 {
00075 if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
00076 {
00077 include(BASEPATH.'language/'.$idiom.'/'.$langfile);
00078 }
00079 else
00080 {
00081 show_error('Unable to load the requested language file: language/'.$langfile);
00082 }
00083 }
00084
00085
00086 if ( ! isset($lang))
00087 {
00088 log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
00089 return;
00090 }
00091
00092 if ($return == TRUE)
00093 {
00094 return $lang;
00095 }
00096
00097 $this->is_loaded[] = $langfile;
00098 $this->language = array_merge($this->language, $lang);
00099 unset($lang);
00100
00101 log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
00102 return TRUE;
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 function line($line = '')
00115 {
00116 $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
00117 return $line;
00118 }
00119
00120 }
00121
00122
00123
00124