language
This commit is contained in:
parent
cadfcf6028
commit
666b1f3f83
|
@ -16,7 +16,7 @@ require_once("../src/functions.php");
|
|||
|
||||
|
||||
|
||||
$arenas=arenas_get_list();
|
||||
$arenas=get_arenas_list();
|
||||
|
||||
//form submitting
|
||||
if (isset($_POST['xd_check']))
|
||||
|
@ -34,8 +34,6 @@ if (isset($_POST['xd_check']))
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
function arenas_get_list(){
|
||||
function get_arenas_list(){
|
||||
include (__DIR__."/arenas_lists.php");
|
||||
if(isset($_GET['arena'])){
|
||||
foreach ($arenas as $arena){
|
||||
|
@ -10,4 +10,37 @@ function arenas_get_list(){
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user