3 * This software is governed by the CeCILL-B license. If a copy of this license
4 * is not distributed with this file, you can obtain one at
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
7 * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
8 * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
10 * =============================
12 * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
13 * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
14 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
16 * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
17 * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
20 asort($ALLOWED_LANGUAGES);
22 if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES)) ) {
23 $mlocale = $_POST['lang'] ;
24 setcookie('lang' , $_POST['lang'], time()+
60*5);
25 } elseif ( isset($_COOKIE['lang']) && is_string($_COOKIE['lang']) && in_array($_COOKIE['lang'], array_keys($ALLOWED_LANGUAGES)) ) {
26 $mlocale = $_COOKIE['lang'] ;
30 // Replace config language by browser language if possible
31 foreach ($ALLOWED_LANGUAGES as $k => $v ) {
32 if (substr($k,0,2)==substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) {
39 $locale = $mlocale . '.utf8';//unix format
40 if (strtoupper(substr(PHP_OS
,0,3))=='WIN'){
41 putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages
43 case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime()
44 case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
45 case 'de_DE' : $locale = "deu";break;
46 case 'es_ES' : $locale = "esp";break;
50 putenv('LANGUAGE=');//sert à quoi?
51 setlocale(LC_ALL
, $locale);
52 setlocale(LC_TIME
, $locale);
53 setlocale(LC_MESSAGES
, $locale);
56 bindtextdomain($domain, 'locale');
57 bind_textdomain_codeset($domain, 'UTF-8');
60 /* temp, for compatibility :*/
61 $a = explode('_', $mlocale);
62 $_SESSION['langue'] = strtoupper($a[0]);
64 /* <html lang="$lang"> */
65 $lang = ($_SESSION['langue']!='') ?
strtolower($_SESSION['langue']) : 'fr';
69 $date_format['txt_full'] = _("%A, den %e. %B %Y"); //summary in choix_date.php and removal date in choix_(date|autre).php
70 $date_format['txt_short'] = "%A %e %B %Y"; // radio title
71 $date_format['txt_day'] = "%a %e";
72 if (strtoupper(substr(PHP_OS
,0,3))=='WIN'){ //%e can't be used on Windows platform, use %#d instead
73 foreach($date_format as $k => $v) {
74 $date_format[$k] = preg_replace('#(?<!%)((?:%%)*)%e#','\1%#d', $v); //replace %e by %#d for windows