Modify to go back to old behavior (load langs only on first use of translate()

This commit is contained in:
Miles Lott 2002-02-20 04:44:19 +00:00
parent 15bc5ac202
commit 54ce2d1d33

View File

@ -28,8 +28,9 @@
class translation class translation
{ {
var $lang = array(); var $lang = array();
var $userlang = ''; var $userlang = 'en';
var $currentapp = ''; var $currentapp = '';
var $loaded = False;
/*! /*!
@function translation @function translation
@ -43,13 +44,12 @@
{ {
$this->userlang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']; $this->userlang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
} }
else
{
$this->userlang = 'en';
}
$this->currentapp = $GLOBALS['phpgw_info']['flags']['currentapp']; $this->currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
}
function load_langs()
{
$sql = "SELECT message_id,content FROM phpgw_lang WHERE lang LIKE '" . $this->userlang $sql = "SELECT message_id,content FROM phpgw_lang WHERE lang LIKE '" . $this->userlang
. "' AND (app_name LIKE '" . $this->currentapp . "' AND (app_name LIKE '" . $this->currentapp
. "' OR app_name LIKE 'common' OR app_name LIKE 'all') ORDER BY app_name "; . "' 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, /* 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; it could be done here. - $GLOBALS['lang'] = $this->lang;
*/ */
$this->loaded = True;
} }
/*! /*!
@ -92,7 +93,12 @@
$ret = $key; $ret = $key;
$_key = strtolower($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; $ndx = 1;
while(list($key,$val) = each($vars)) while(list($key,$val) = each($vars))