summaryrefslogtreecommitdiffstats
path: root/system/core/Lang.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2010-03-02 20:39:48 +0100
committerDerek Jones <derek.jones@ellislab.com>2010-03-02 20:39:48 +0100
commit692c5486cdcfc05cd9dc6f348b09bc093b32eea8 (patch)
tree7beba12416b6cbf9b1045c0a418ed1da7bdbea11 /system/core/Lang.php
parent69fc4fc9e729f8ef510150ea01185923bffaf58b (diff)
renamed class
added ability to specify arbitrary path for language file (packages!) added ability to specify lang files that don't end in _lang, or to call file with _lang directly without it adding another _lang suffix
Diffstat (limited to 'system/core/Lang.php')
-rw-r--r--system/core/Lang.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/system/core/Lang.php b/system/core/Lang.php
index bbecab645..e071495b8 100644
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -24,7 +24,7 @@
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/language.html
*/
-class CI_Language {
+class CI_Lang {
var $language = array();
var $is_loaded = array();
@@ -34,7 +34,7 @@ class CI_Language {
*
* @access public
*/
- function CI_Language()
+ function CI_Lang()
{
log_message('debug', "Language Class Initialized");
}
@@ -49,24 +49,36 @@ class CI_Language {
* @param string the language (english, etc.)
* @return mixed
*/
- function load($langfile = '', $idiom = '', $return = FALSE)
+ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
- $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
+ $langfile = str_replace(EXT, '', $langfile);
+
+ if ($add_suffix == TRUE)
+ {
+ $langfile = str_replace('_lang.', '', $langfile).'_lang';
+ }
+
+ $langfile .= EXT;
if (in_array($langfile, $this->is_loaded, TRUE))
{
return;
}
+ $config =& get_config();
+
if ($idiom == '')
{
- $CI =& get_instance();
- $deft_lang = $CI->config->item('language');
+ $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
}
// Determine where the language file is and load it
- if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
+ if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
+ {
+ include($alt_path.'language/'.$idiom.'/'.$langfile);
+ }
+ elseif (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
{
include(APPPATH.'language/'.$idiom.'/'.$langfile);
}
@@ -82,6 +94,7 @@ class CI_Language {
}
}
+
if ( ! isset($lang))
{
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
@@ -119,5 +132,5 @@ class CI_Language {
}
// END Language Class
-/* End of file Language.php */
-/* Location: ./system/core/Language.php */ \ No newline at end of file
+/* End of file Lang.php */
+/* Location: ./system/core/Lang.php */ \ No newline at end of file