]> git.mxchange.org Git - friendica.git/commitdiff
Autodetect browser language (should we make this optional?)
authorolivierm <olivier@migeot.org>
Tue, 8 Mar 2011 13:41:04 +0000 (14:41 +0100)
committerolivierm <olivier@migeot.org>
Tue, 8 Mar 2011 13:41:04 +0000 (14:41 +0100)
index.php

index bbd2c81cd67468adb70227688d9993056eab30b4..24466a85acd5afe78832495c675cacf191ea31e1 100644 (file)
--- a/index.php
+++ b/index.php
@@ -31,10 +31,17 @@ $install = ((file_exists('.htconfig.php')) ? false : true);
  *
  * 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);