]>
jfr.im git - z_archive/KronOS.git/blob - system/core/Lang.php
1 <?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
21 * @package CodeIgniter
22 * @subpackage Libraries
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/libraries/language.html
30 * List of translations
34 var $language = array();
36 * List of loaded language files
40 var $is_loaded = array();
47 function __construct()
49 log_message('debug', "Language Class Initialized");
52 // --------------------------------------------------------------------
55 * Load a language file
58 * @param mixed the name of the language file to be loaded. Can be an array
59 * @param string the language (english, etc.)
60 * @param bool return loaded array of translations
61 * @param bool add suffix to $langfile
62 * @param string alternative path to look for language file
65 function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
67 $langfile = str_replace('.php', '', $langfile);
69 if ($add_suffix == TRUE)
71 $langfile = str_replace('_lang.', '', $langfile).'_lang';
76 if (in_array($langfile, $this->is_loaded
, TRUE))
81 $config =& get_config();
85 $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
86 $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
89 // Determine where the language file is and load it
90 if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
92 include($alt_path.'language/'.$idiom.'/'.$langfile);
98 foreach (get_instance()->load
->get_package_paths(TRUE) as $package_path)
100 if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
102 include($package_path.'language/'.$idiom.'/'.$langfile);
110 show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
117 log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
126 $this->is_loaded
[] = $langfile;
127 $this->language
= array_merge($this->language
, $lang);
130 log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
134 // --------------------------------------------------------------------
137 * Fetch a single line of text from the language array
140 * @param string $line the language line
143 function line($line = '')
145 $value = ($line == '' OR ! isset($this->language
[$line])) ? FALSE : $this->language
[$line];
147 // Because killer robots like unicorns!
148 if ($value === FALSE)
150 log_message('error', 'Could not find the language line "'.$line.'"');
157 // END Language Class
159 /* End of file Lang.php */
160 /* Location: ./system/core/Lang.php */