diff options
author | Anton Lindqvist <anton@qvister.se> | 2012-06-08 10:09:47 +0200 |
---|---|---|
committer | Anton Lindqvist <anton@qvister.se> | 2012-06-08 10:09:47 +0200 |
commit | 94c6b1f1c02466178c1f8e144542d753f27dd3d8 (patch) | |
tree | 8e8ca4b8383e2481b0a689fd07fc230013531822 /system/core/Lang.php | |
parent | 6581cac4d2b5fef69478ce1a5c3464200bfcbba5 (diff) | |
parent | c78e56a7df140ee777ffc67687877f3e70c77e28 (diff) |
Merge branch 'develop' of https://github.com/EllisLab/CodeIgniter into develop
Conflicts:
system/libraries/Cache/Cache.php
Diffstat (limited to 'system/core/Lang.php')
-rwxr-xr-x | system/core/Lang.php | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/system/core/Lang.php b/system/core/Lang.php index 9ef76f4d6..3001f1b13 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Language Class * @@ -43,14 +41,20 @@ class CI_Lang { * * @var array */ - public $language = array(); + public $language = array(); + /** * List of loaded language files * * @var array */ - public $is_loaded = array(); + public $is_loaded = array(); + /** + * Initialize language class + * + * @return void + */ public function __construct() { log_message('debug', 'Language Class Initialized'); @@ -61,39 +65,37 @@ class CI_Lang { /** * Load a language file * - * @param mixed the name of the language file to be loaded. Can be an array + * @param mixed the name of the language file to be loaded * @param string the language (english, etc.) * @param bool return loaded array of translations * @param bool add suffix to $langfile * @param string alternative path to look for language file * @return mixed */ - public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') + public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { $langfile = str_replace('.php', '', $langfile); - if ($add_suffix == TRUE) + if ($add_suffix === TRUE) { - $langfile = str_replace('_lang.', '', $langfile).'_lang'; + $langfile = str_replace('_lang', '', $langfile).'_lang'; } $langfile .= '.php'; - if (in_array($langfile, $this->is_loaded, TRUE)) + if ($idiom === '') { - return; + $config =& get_config(); + $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; } - $config =& get_config(); - - if ($idiom == '') + if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { - $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language']; - $idiom = ($deft_lang == '') ? 'english' : $deft_lang; + return; } // Determine where the language file is and load it - if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) { include($alt_path.'language/'.$idiom.'/'.$langfile); } @@ -121,17 +123,21 @@ class CI_Lang { if ( ! isset($lang) OR ! is_array($lang)) { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); + + if ($return === TRUE) + { + return array(); + } return; } - if ($return == TRUE) + if ($return === TRUE) { return $lang; } - $this->is_loaded[] = $langfile; + $this->is_loaded[$langfile] = $idiom; $this->language = array_merge($this->language, $lang); - unset($lang); log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); return TRUE; @@ -147,7 +153,7 @@ class CI_Lang { */ public function line($line = '') { - $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; // Because killer robots like unicorns! if ($value === FALSE) @@ -161,4 +167,4 @@ class CI_Lang { } /* End of file Lang.php */ -/* Location: ./system/core/Lang.php */ +/* Location: ./system/core/Lang.php */
\ No newline at end of file |