This commit is contained in:
Gnieark 2015-11-26 19:38:09 +01:00
parent cadfcf6028
commit 666b1f3f83
2 changed files with 35 additions and 4 deletions

View File

@ -16,7 +16,7 @@ require_once("../src/functions.php");
$arenas=arenas_get_list(); $arenas=get_arenas_list();
//form submitting //form submitting
if (isset($_POST['xd_check'])) if (isset($_POST['xd_check']))
@ -34,8 +34,6 @@ if (isset($_POST['xd_check']))
} }
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">

View File

@ -1,5 +1,5 @@
<?php <?php
function arenas_get_list(){ function get_arenas_list(){
include (__DIR__."/arenas_lists.php"); include (__DIR__."/arenas_lists.php");
if(isset($_GET['arena'])){ if(isset($_GET['arena'])){
foreach ($arenas as $arena){ foreach ($arenas as $arena){
@ -11,3 +11,36 @@ function arenas_get_list(){
} }
return $arenas; return $arenas;
} }
function get_language_array(){
/*
* Choisir la langue de l'utilisateur
* en priorisant parametre GET, cookie, info du navigateur
* Retourner l'array contenant les bonnes traductions
*/
$langsAvailable=array('fr','en');
$language="";
if( $_GET['lang'] ){
$lang = $_GET['lang'];
setcookie( 'lang', $language, time() + 60*60*24*30 );
}elseif( isset($_COOKIE['lang']) ){
$language=$_COOKIE['lang'];
}else{
if(in_array(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2),$langsAvailable)){
$language=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
}
if(!in_array($language,$langsAvailable)){
$language="en";
}
include (__DIR__."/../lang/".$language.".php");
return $lang;
}