summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2012-12-31 15:11:45 +0000
committerArun Persaud <arun@nubati.net>2012-12-31 15:11:45 +0000
commitaeb9ef98850e762291bc6a1d39b31d1ac4db4817 (patch)
tree263ce358d5299b3b1214279b58b33ba9bf73f4ca /index.php
parent059f17ad6897e250b2bdfdc9837a39af62859d7e (diff)
downloade-DoKo-aeb9ef98850e762291bc6a1d39b31d1ac4db4817.tar.gz
e-DoKo-aeb9ef98850e762291bc6a1d39b31d1ac4db4817.tar.bz2
e-DoKo-aeb9ef98850e762291bc6a1d39b31d1ac4db4817.zip
improved language detection using browser information; set the language directly in more places
previously one had to reload to get the language correct, now it should be correct right away. We also read out the browser request for a language now.
Diffstat (limited to 'index.php')
-rw-r--r--index.php43
1 files changed, 19 insertions, 24 deletions
diff --git a/index.php b/index.php
index bbdfeb2..2a55ed8 100644
--- a/index.php
+++ b/index.php
@@ -51,33 +51,28 @@ if($DBopen<0)
exit();
}
-/* localization */
+/**** localization ****/
/* needs to be in front of output_header, but we don't know the users preferences at this time,
* so we go by the session variable or if language is set
*/
-if(myisset('language') || isset($_SESSION['language']))
- {
- $language = 'en';
-
- if(myisset('language'))
- $language = $_REQUEST['language'];
- else if(isset($_SESSION['language']))
- $language = $_SESSION['language'];
-
- switch($language)
- {
- case 'de':
- putenv("LC_ALL=de_DE");
- setlocale(LC_ALL, "de_DE");
- // Specify location of translation tables
- bindtextdomain("edoko", "./locale");
- // Choose domain
- textdomain("edoko");
- break;
- default:
- /* do nothing */
- }
- }
+/* set default */
+$language = detectlanguage();
+
+/* check if default in array of supported languages, else default to english */
+$supported_languages = array ('en','de');
+
+if ( !in_array($language, $supported_languages) )
+ $language = 'en';
+
+/* override with explicit request from user */
+if(myisset('language'))
+ $language = $_REQUEST['language'];
+else if(isset($_SESSION['language']))
+ $language = $_SESSION['language'];
+
+/* set it */
+set_language($language);
+/**** end language ****/
/* done major error checking, output header of HTML page */
output_header();