aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_user.inc.php
diff options
context:
space:
mode:
authorvdigital <vdigital@piwigo.org>2008-05-31 11:43:13 +0000
committervdigital <vdigital@piwigo.org>2008-05-31 11:43:13 +0000
commit6d8c172ee2e06b2f9e14f9189273403a990cdefa (patch)
tree44ceb3d753a5242fe58379ff020c49cd904c5640 /include/functions_user.inc.php
parent93a4c7a150346956c8a53a0255d1e4ed6c334260 (diff)
Feature 0000080: Browser language detection (Use first active browser language as language for guest, generic members, registering process). If the language is not available PHPWG_DEFAULT_LANGUAGE is used as previously.
git-svn-id: http://piwigo.org/svn/trunk@2371 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_user.inc.php')
-rw-r--r--include/functions_user.inc.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index d2c9530e2..58b35e541 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -838,7 +838,32 @@ function get_default_template()
*/
function get_default_language()
{
- return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
+ global $conf;
+ if (isset($conf['browser_language']) and $conf['browser_language'])
+ {
+ return get_browser_language();
+ }
+ else
+ {
+ return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE);
+ }
+}
+
+/*
+ * Returns the browser language value
+ *
+ */
+function get_browser_language()
+{
+ $browser_language = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
+ foreach (get_languages() as $language_code => $language_name)
+ {
+ if (substr($language_code, 0, 2) == $browser_language)
+ {
+ return $language_code;
+ }
+ }
+ return PHPWG_DEFAULT_LANGUAGE;
}
/**
@@ -898,6 +923,7 @@ function create_user_infos($arg_id, $override_values = null)
{
$status = 'normal';
}
+ $default_user['language'] = get_default_language();
$insert = array_merge(
$default_user,