From 54ce2d1d33037fec23ef4670fdde03d03c82adc5 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Wed, 20 Feb 2002 04:44:19 +0000 Subject: [PATCH] Modify to go back to old behavior (load langs only on first use of translate() --- phpgwapi/inc/class.translation_sql.inc.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/phpgwapi/inc/class.translation_sql.inc.php b/phpgwapi/inc/class.translation_sql.inc.php index 99969d71f0..8bc996d786 100644 --- a/phpgwapi/inc/class.translation_sql.inc.php +++ b/phpgwapi/inc/class.translation_sql.inc.php @@ -28,8 +28,9 @@ class translation { var $lang = array(); - var $userlang = ''; + var $userlang = 'en'; var $currentapp = ''; + var $loaded = False; /*! @function translation @@ -43,13 +44,12 @@ { $this->userlang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']; } - else - { - $this->userlang = 'en'; - } $this->currentapp = $GLOBALS['phpgw_info']['flags']['currentapp']; + } + function load_langs() + { $sql = "SELECT message_id,content FROM phpgw_lang WHERE lang LIKE '" . $this->userlang . "' AND (app_name LIKE '" . $this->currentapp . "' OR app_name LIKE 'common' OR app_name LIKE 'all') ORDER BY app_name "; @@ -75,6 +75,7 @@ /* Done stuffing the array. If someone prefers to have $GLOBALS['lang'] set to this as before, it could be done here. - $GLOBALS['lang'] = $this->lang; */ + $this->loaded = True; } /*! @@ -92,7 +93,12 @@ $ret = $key; $_key = strtolower($key); - $ret = $this->lang[$_key] ? $this->lang[$_key] : $key . '*'; + if(!@isset($this->lang[$_key]) && !$this->loaded) + { + $this->load_langs(); + } + + $ret = @isset($this->lang[$_key]) ? $this->lang[$_key] : $key . '*'; $ndx = 1; while(list($key,$val) = each($vars))