load_lang.php 771 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once __DIR__.'/../path.php';
  3. /*
  4. load language file
  5. 范例
  6. echo $_local->gui->;
  7. <?php echo $_local->gui->;?>
  8. */
  9. if(isset($_GET["language"])){
  10. $currLanguage=$_GET["language"];
  11. }
  12. else{
  13. if(isset($_COOKIE["language"])){
  14. $currLanguage=$_COOKIE["language"];
  15. }
  16. else{
  17. $currLanguage="en";
  18. }
  19. }
  20. setcookie("language", $currLanguage, time()+60*60*24*365,"/");
  21. if(file_exists(_DIR_LANGUAGE_.'/'.$currLanguage.".json")){
  22. $_local=json_decode(file_get_contents(_DIR_LANGUAGE_.'/'.$currLanguage.".json"));
  23. $_local_arr=json_decode(file_get_contents(_DIR_LANGUAGE_.'/'.$currLanguage.".json"),true);
  24. }
  25. else{
  26. $_local=json_decode(file_get_contents(_DIR_LANGUAGE_."/default.json"));
  27. $_local_arr=json_decode(file_get_contents(_DIR_LANGUAGE_."/default.json"),true);
  28. }
  29. ?>