système multilingue avec du json
Bonjour,
je tente de faire marcher un système multilingue où les traductions sont des fichiers json. Mais la variable (de type objet) censée contenir les traductions est vide. Pourquoi ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| $lang=getPageLanguage($_SESSION['lang'],['header',$page,'footer']);
debug($lang);
function getPageLanguage($lang,$pages) {
$dataPage=[];
foreach($pages as $p){
$jsonString=file_get_contents('_lang/'.$lang.'/'.$p.'.json');
$json=json_decode($jsonString);
$datePage[$p]=$json;
};
return (object) $dataPage;
} |
la fonction debug (mise en forme d'un var_dump) donne
Citation:
deb
C:\wamp64\www\mvc_udemy\_functions\functions.php:18:
object(stdClass)[6]
fin
Il y a bien 6 fichiers json. Voici un de ces fichiers :
home.json :
Où est mon bug ?