From aeb9ef98850e762291bc6a1d39b31d1ac4db4817 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 31 Dec 2012 15:11:45 +0000 Subject: 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. --- include/functions.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index cb78457..1f8f2cc 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1699,4 +1699,32 @@ function verify_password($email, $password) return 3; } +/* language functions */ +function detectlanguage() +{ + /* read out browser's prefered language, taken from php-manual*/ + $langcode = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']); + $langcode = explode(",", $langcode['0']); + return $langcode['0']; +} + +function set_language($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 */ + } + + return; +} + ?> -- cgit v1.2.3-18-g5258