[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 * Gestion de la langue 6 7 * @Version $Id lang.inc.php 1923 2007-03-10 14:25:26Z crob $ 8 9 * @Projet LCS / SambaEdu 10 11 * @Auteurs Laurent COOPER 12 * @auteurs Philippe Chadefaux (Modified for Se3) 13 14 * @Note This script is part of the SLIS Project initiated by the CARMI-Internet (Academie de Grenoble - France 38) 15 16 * @Licence Distribue sous la licence GPL 17 */ 18 19 /** 20 21 * file: lang.inc.php 22 * @Repertoire: includes/ 23 */ 24 25 26 27 28 require ("config.inc.php"); 29 30 /* 31 if($langue != "fr") { 32 if($langue !="auto") { 33 putenv("LANG=$langue"); 34 putenv("LANGUAGE=$langue"); 35 @setlocale('LC_ALL', $langue); 36 */ 37 if($lang != "fr") { 38 if($lang !="auto") { 39 putenv("LANG=$lang"); 40 putenv("LANGUAGE=$lang"); 41 @setlocale('LC_ALL', $lang); 42 } else { 43 44 // put here the langage for wich the interface is translated. fr_FR, or fr ... 45 $Interface_Lang=array('en_GB','fr_FR','de_DE','es'); 46 47 // Get browser accepted language and set to english if none. 48 49 $Server_Lang=@preg_split("/,/",(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? 'en_US' : 50 $_SERVER["HTTP_ACCEPT_LANGUAGE"])); 51 // Determinate the score for each language. In case the browser returns no score, decalate in order 52 //fr-fr also allow fr to be chosen... 53 $sorting_param=0.01; 54 foreach ($Server_Lang as $part) { 55 $part=trim($part); 56 if(preg_match("/;/", $part)) { 57 $lang=@preg_split("/;/",$part); 58 $score=@preg_split("/=/",$lang[1]); 59 $lang_scores[$lang[0]]=$score[1]; 60 if (preg_match("/-/",$lang[0])) { 61 $noct=@preg_split("/-/",$lang[0]); 62 $lang_scores[$noct[0]]=$score[1]-$sorting_param; 63 } 64 } else { 65 $lang_scores[$part]=1-$sorting_param; 66 if (preg_match("/-/",$part)) { 67 $noct=@preg_split("/-/",$part); 68 $lang_scores[$noct[0]]=1-$sorting_param; 69 } 70 $sorting_param = $sorting_param +0.01; 71 } 72 } 73 74 // Now search for the language available with the highest score. 75 76 $curlscore=0; 77 $curlang=NULL; 78 foreach($Interface_Lang as $ilang) { 79 $tmp=preg_replace("/\_/","-",$ilang); 80 $allang=strtolower($tmp); 81 $noct=@preg_split("/-/",$allang); 82 83 $testvals=array($lang_scores[$allang],$lang_scores[$noct[0]]); 84 $found=FALSE; 85 foreach($testvals as $tval) { 86 if(!$found && isset($tval)) { 87 if ($curlscore<$tval) { 88 $curlscore=$tval; 89 $curlang=$ilang; 90 $found=TRUE;} 91 } 92 } 93 } 94 95 if (! isset($curlang)) { 96 $curlang='en_US'; 97 } 98 99 if (preg_match("/\_/",$curlang)){ 100 $lang_tmp=@preg_split("/\_/",$curlang); 101 $langage=$lang_tmp[0]; 102 } 103 else { 104 $langage=$curlang; 105 } 106 /* 107 putenv("LANG=$curlang"); 108 putenv("LANGUAGE=$curlang"); 109 @setlocale('LC_ALL', $curlang); 110 */ 111 putenv("LANG=$langage"); 112 putenv("LANGUAGE=$langage"); 113 @setlocale('LC_ALL', $langage); 114 } 115 } 116 117 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |