From 1e43e837c0f4f344560deee5a988b0b5f4d176ca Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 6 Jul 2009 09:25:19 +0000 Subject: [PATCH] fix regarding get_app in translation. array_merge does renumber and += seems to bear problems, if there already is a translation for the given key (mainscreen_message) --- phpgwapi/inc/class.translation.inc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index d7619bbda0..0237686ca4 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -245,15 +245,19 @@ class translation static function add_app($app,$lang=False) { $lang = $lang ? $lang : self::$userlang; - if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang) { //$start = microtime(true); // for loginscreen we have to use a instance specific cache! $loaded =& egw_cache::getCache(in_array($app,self::$instance_specific_translations) ? egw_cache::INSTANCE : egw_cache::TREE, __CLASS__,$app.':'.$lang,array(__CLASS__,'load_app'),array($app,$lang)); - - self::$lang_arr += $loaded; // use += instead of array_merge, as we have phrases with numerical index, which get renumbered by array_merge + foreach(array_keys($loaded) as $key) + { + // as array_merge does renumber, and the padding of the loaded langs to the existing langs does lead to strange phenomenons + // regarding the mainscreen_message, we do that the old fashioned way. + if (!empty($loaded[$key])) self::$lang_arr[$key] = $loaded[$key]; + } + //self::$lang_arr += $loaded; // use += instead of array_merge, as we have phrases with numerical index, which get renumbered by array_merge self::$loaded_apps[$app] = $lang; //error_log(__METHOD__."($app,$lang) took ".(1000*(microtime(true)-$start))." ms, loaded ".count($loaded)." phrases -> total=".count(self::$lang_arr).": ".function_backtrace()); }