From ac86714bc5b6e39ff8d06ce1a041c8667312864b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 19 Oct 2007 13:09:04 +0000 Subject: [PATCH] allow mixed installations of trunk and 1.4 apps, by reading both langfiles --- phpgwapi/inc/class.translation.inc.php | 52 +++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 67d7ac19f4..9440ba3636 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -39,6 +39,10 @@ { define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); } + + // Define prefix for langfiles (historically 'phpgw_') + define('EGW_LANGFILE_PREFIX', 'egw_'); + define('PHPGW_LANGFILE_PREFIX', 'phpgw_'); class translation { @@ -238,26 +242,30 @@ */ function add_setup($lang) { - $fn = EGW_SERVER_ROOT.'/setup/lang/phpgw_' . $lang . '.lang'; - if (!file_exists($fn)) + foreach(array( + EGW_SERVER_ROOT.'/setup/lang/' . EGW_LANGFILE_PREFIX . $lang . '.lang', + EGW_SERVER_ROOT.'/setup/lang/' . PHPGW_LANGFILE_PREFIX . $lang . '.lang', + EGW_SERVER_ROOT.'/setup/lang/' . EGW_LANGFILE_PREFIX . 'en.lang', + EGW_SERVER_ROOT.'/setup/lang/' . PHPGW_LANGFILE_PREFIX . 'en.lang', + ) as $fn) { - $fn = EGW_SERVER_ROOT.'/setup/lang/phpgw_en.lang'; - } - if (file_exists($fn)) - { - $fp = fopen($fn,'r'); - while ($data = fgets($fp,8000)) + if (file_exists($fn)) { - // explode with "\t" and removing "\n" with str_replace, needed to work with mbstring.overload=7 - list($message_id,,,$content) = explode("\t",$data); - $phrases[strtolower(trim($message_id))] = str_replace("\n",'',$content); - } - fclose($fp); - - foreach($phrases as $message_id => $content) - { - $this->lang_arr[$message_id] = $this->convert($content,$phrases['charset']); + $fp = fopen($fn,'r'); + while ($data = fgets($fp,8000)) + { + // explode with "\t" and removing "\n" with str_replace, needed to work with mbstring.overload=7 + list($message_id,,,$content) = explode("\t",$data); + $phrases[strtolower(trim($message_id))] = str_replace("\n",'',$content); + } + fclose($fp); + + foreach($phrases as $message_id => $content) + { + $this->lang_arr[$message_id] = $this->convert($content,$phrases['charset']); + } } + break; } $this->loaded_apps['setup'] = $lang; } @@ -552,9 +560,10 @@ // Visit each app/setup dir, look for a egw_lang file foreach($apps as $app) { - $appfile = EGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang'; + $appfile = EGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . EGW_LANGFILE_PREFIX . strtolower($lang) . '.lang'; + $old_appfile = EGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . PHPGW_LANGFILE_PREFIX . strtolower($lang) . '.lang'; //echo '
Checking in: ' . $app; - if($GLOBALS['egw_setup']->app_registered($app) && file_exists($appfile)) + if($GLOBALS['egw_setup']->app_registered($app) && (file_exists($appfile) || file_exists($appfile=$old_appfile))) { //echo '
Including: ' . $appfile; $lines = file($appfile); @@ -679,9 +688,10 @@ $apps['phpgwapi'] = True; // check the api too foreach($apps as $app => $data) { - $fname = EGW_SERVER_ROOT . "/$app/setup/phpgw_$lang.lang"; + $fname = EGW_SERVER_ROOT . "/$app/setup/" . EGW_LANGFILE_PREFIX . "$lang.lang"; + $old_fname = EGW_SERVER_ROOT . "/$app/setup/" . PHPGW_LANGFILE_PREFIX . "$lang.lang"; - if (file_exists($fname)) + if (file_exists($fname) || file_exists($fname = $old_fname)) { $ctime = filectime($fname); /* This is done to avoid string offset error at least in php5 */