From 817f7604c672e8500284fc4396f6e8e51f4c9e8a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 3 Jan 2008 00:38:30 +0000 Subject: [PATCH] #2069 Locale file /lang/en_US.php should exist (Windows) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47580 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/i18n.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/i18n.php b/core/i18n.php index 5311ed64b..1bbefc79c 100755 --- a/core/i18n.php +++ b/core/i18n.php @@ -926,14 +926,14 @@ class i18n extends Controller { protected static function get_owner_module($name) { if (substr($name,-3) == '.ss') { global $_TEMPLATE_MANIFEST; - $path = current($_TEMPLATE_MANIFEST[substr($name,0,-3)]); - ereg(Director::baseFolder() . '/([^/]+)/',$path,$module); + $path = str_replace('\\','/',Director::makeRelative(current($_TEMPLATE_MANIFEST[substr($name,0,-3)]))); + ereg('/([^/]+)/',$path,$module); } else { global $_CLASS_MANIFEST; - $path = $_CLASS_MANIFEST[$name]; - ereg(Director::baseFolder() . '/([^/]+)/',$path,$module); + $path = str_replace('\\','/',Director::makeRelative($_CLASS_MANIFEST[$name])); + ereg('/([^/]+)/', $path, $module); } - return $module[1]; + return ($module) ? $module[1] : false; } @@ -1245,13 +1245,15 @@ class i18n extends Controller { */ static function include_by_class($class) { $module = self::get_owner_module($class); + if(!$module) user_error("i18n::include_by_class: Class {$class} not found", E_USER_WARNING); + if (file_exists($file = Director::getAbsFile("$module/lang/". self::get_locale() . '.php'))) { include_once($file); } else if (self::get_locale() != 'en_US') { self::set_locale('en_US'); self::include_by_class($class); } else { - user_error("Locale file $file should exist", E_USER_WARNING); + user_error("i18n::include_by_class: Locale file $file should exist", E_USER_WARNING); } } @@ -1316,4 +1318,4 @@ class i18n extends Controller { } } -?> +?> \ No newline at end of file