summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-26 22:01:24 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-26 22:01:24 +0100
commitb11b9f38f3ae0f9699612ac61000ee789665f2d6 (patch)
treec271a97b7d0d4391f1ef4942a04d826ee5e522b9 /system
parentdaaca882e48e26e60bf2eea9f4fad108a845fb38 (diff)
Implement cascade-style loading of language files
(as requested in issue #452)
Diffstat (limited to 'system')
-rw-r--r--system/core/Lang.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/system/core/Lang.php b/system/core/Lang.php
index 5d824cee6..47f6c00ee 100644
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -96,29 +96,40 @@ class CI_Lang {
return;
}
- // Determine where the language file is and load it
- if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
+ // Load the base file, so any others found can override it
+ $basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
+ if (($found = file_exists($basepath)) === TRUE)
{
- include($alt_path.'language/'.$idiom.'/'.$langfile);
+ include($basepath);
+ }
+
+ // Do we have an alternative path to look in?
+ if ($alt_path !== '')
+ {
+ $alt_path .= 'language/'.$idiom.'/'.$langfile;
+ if (file_exists($alt_path))
+ {
+ include($alt_path);
+ $found = TRUE;
+ }
}
else
{
- $found = FALSE;
-
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
{
- if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
+ $package_path .= 'language/'.$idiom.'/'.$langpath;
+ if ($basepath !== $package_path && file_exists($package_path))
{
- include($package_path.'language/'.$idiom.'/'.$langfile);
+ include($package_path);
$found = TRUE;
break;
}
}
+ }
- if ($found !== TRUE)
- {
- show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
- }
+ if ($found !== TRUE)
+ {
+ show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
}
if ( ! isset($lang) OR ! is_array($lang))