aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/config_default.inc.php4
-rw-r--r--include/functions_user.inc.php28
-rw-r--r--include/user.inc.php5
3 files changed, 35 insertions, 2 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index f5c9d64c8..e7a8c117d 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -473,6 +473,10 @@ $conf['guest_id'] = 2;
// default_user_id : id of user used for default value
$conf['default_user_id'] = $conf['guest_id'];
+// Registering process and guest/generic members get language from the browser
+// if language isn't available PHPWG_DEFAULT_LANGUAGE is used as previously
+$conf['browser_language'] = true;
+
// webmaster_id : webmaster'id.
$conf['webmaster_id'] = 1;
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,
diff --git a/include/user.inc.php b/include/user.inc.php
index b267790f8..1cb9ce7c0 100644
--- a/include/user.inc.php
+++ b/include/user.inc.php
@@ -69,6 +69,9 @@ if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
$user = build_user( $user['id'],
( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
);
-
+if (is_a_guest() or is_generic())
+{
+ $user['language'] = get_default_language();
+}
trigger_action('user_init', $user);
?>