2 /*------------------------------------------------------------
3 * CarbonPHP framework (C) Tom Bell
4 * http://tombell.org.uk
5 *------------------------------------------------------------*/
7 if (!defined('CARBON_PATH'))
9 exit('Direct script access is not allowed.');
14 protected $language = array();
15 protected $is_loaded = array();
17 public function __construct()
19 log_message('debug', 'Language.php - Carbon_Language class initialised');
22 public function load($langfile = '', $idiom = '', $return = false)
24 $langfile = str_replace(FILE_EXT
, '', str_replace('_lang.', '', $langfile)) . '_lang' . FILE_EXT
;
26 if (in_array($langfile, $this->is_loaded
, true))
33 $carbon =& get_instance();
34 $def_lang = $carbon->config
->get_config_item('language');
35 $idiom = ($def_lang == '') ?
'engliah' : $def_lang;
38 if (file_exists(APP_PATH
. 'languages/' . $idiom . '/' . $langfile))
40 include(APP_PATH
. 'languages/' . $idiom . '/' . $langfile);
44 if (file_exists(CARBON_PATH
. 'languages/' . $idiom . '/' . $langfile))
46 include(CARBON_PATH
. 'languages/' . $idiom . '/' . $langfile);
50 display_error('Unable to load the language file: languages/' . $langfile);
56 log_message('error', 'Language.php - Langauge file contains no data: languages/' . $idiom . '/' . $langfile);
65 $this->is_loaded
[] = $langfile;
66 $this->language
= array_merge($this->language
, $lang);
69 log_message('debug', 'Language.php - Language file loaded: languages/' . $idiom . '/' . $langfile);
73 public function line($line = '')
75 return ($line == '' ||
!isset($this->language
[$line])) ?
false : $this->language
[$line];