mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
added funtions for detecting users preferred language automatically
This commit is contained in:
parent
3003566b9d
commit
f9a2fa3840
@ -195,6 +195,7 @@
|
||||
$this->preferences->account_id = $phpgw_info["user"]["account_id"];
|
||||
|
||||
}
|
||||
|
||||
$this->translation = new translation;
|
||||
$this->acl = new acl;
|
||||
|
||||
|
@ -225,6 +225,8 @@
|
||||
$db2->next_record();
|
||||
$pref_info = $db2->f("preference_value");
|
||||
$this->preference = unserialize($pref_info);
|
||||
if ($this->preference["common"]["lang"] == "auto")
|
||||
$this->preference["common"]["lang"] = $phpgw->common->getPreferredLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,55 @@
|
||||
var $key = "";
|
||||
var $crypto;
|
||||
|
||||
// return a array of installed languages
|
||||
function getInstalledLanguages()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$phpgw->db->query("select distinct lang from lang");
|
||||
while (@$phpgw->db->next_record())
|
||||
{
|
||||
$installedLanguages[$phpgw->db->f("lang")] = $phpgw->db->f("lang");
|
||||
}
|
||||
|
||||
return $installedLanguages;
|
||||
}
|
||||
|
||||
// return the preferred language of the users
|
||||
// it's using HTTP_ACCEPT_LANGUAGE (send from the users browser)
|
||||
// and ...(to find out which languages are installed)
|
||||
function getPreferredLanguage()
|
||||
{
|
||||
global $HTTP_ACCEPT_LANGUAGE;
|
||||
|
||||
// create a array of languages the user is accepting
|
||||
$userLanguages = explode(",",$HTTP_ACCEPT_LANGUAGE);
|
||||
$supportedLanguages = $this->getInstalledLanguages();
|
||||
|
||||
// find usersupported language
|
||||
while (list($key,$value) = each($userLanguages))
|
||||
{
|
||||
// remove everything behind "-" example: de-de
|
||||
$value = trim($value);
|
||||
$pieces = explode("-", $value);
|
||||
$value = $pieces[0];
|
||||
# print "current lang $value<br>";
|
||||
if ($supportedLanguages[$value])
|
||||
{
|
||||
$retValue=$value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// no usersupported language found -> return english
|
||||
if (empty($retValue))
|
||||
{
|
||||
$retValue="en";
|
||||
}
|
||||
|
||||
return $retValue;
|
||||
}
|
||||
|
||||
// connect to the ldap server and return a handle
|
||||
function ldapConnect($host = "", $dn = "", $passwd = "")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user