]> git.mxchange.org Git - friendica.git/blobdiff - index.php
revup
[friendica.git] / index.php
index cc17119b62c6c48f92e5b6dc57b483595261d7cf..074c1c53a4452e2fe63f65319bbfe96c39e900ae 100644 (file)
--- a/index.php
+++ b/index.php
@@ -31,10 +31,18 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
  *
  * Get the language setting directly from system variables, bypassing get_config()
  * as database may not yet be configured.
+ * 
+ * If possible, we use the value from the browser.
  *
  */
 
-$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
+if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+       $langs = preg_split("/[,-]/",$_SERVER['HTTP_ACCEPT_LANGUAGE'],2);
+       $lang = $langs[0];
+} else {
+       $lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
+}
+
        
 load_translation_table($lang);
 
@@ -79,6 +87,19 @@ $a->init_pagehead();
 
 session_start();
 
+/**
+ * Language was set earlier, but we can over-ride it in the session.
+ * We have to do it here because the session was just now opened.
+ */
+
+if(x($_POST,'system_language'))
+       $_SESSION['language'] = $_POST['system_language'];
+if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
+       $lang = $_SESSION['language'];
+       load_translation_table($lang);
+}
+
+
 /**
  *
  * For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.