LangGenerator.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <style>
  2. table tr td{
  3. padding:5px;
  4. border:1px solid #cecece;
  5. font-family:Verdana;
  6. font-size:11px;
  7. }
  8. </style>
  9. <?php
  10. $_ = array_map('htmlentities',array_merge($_POST,$_GET));
  11. $currentLang = (isset($_['edit'])?$_['edit']:false); ?>
  12. <form action="#" method="POST">
  13. <table cellspadding="0" cellspacing="0" style="width:100%;">
  14. <tr style="background-color:#000000;color:#ffffff;" >
  15. <td colspan="2">Langue: <input type="text" value="<?php echo $currentLang; ?>" name="lang"> , Charger une langue existante : <select name="langSelection" onchange="if(this.value!='')window.location='LangGenerator.php?edit='+this.value;">
  16. <option value=""></option>
  17. <?php
  18. $langFiles = scandir(dirname(__FILE__));
  19. foreach($langFiles as $file){
  20. if(is_file($file) && strpos($file, '.')===false){
  21. ?><option value="<?php echo $file; ?>"><?php echo $file; ?></option><?php
  22. }
  23. }
  24. ?>
  25. </select></td>
  26. </tr>
  27. <?php
  28. $template = file((!$currentLang?'fr - Francais':$currentLang));
  29. $refTab = array();
  30. $refNum = 0;
  31. foreach($template as $line){
  32. list($key,$value) = explode('[::->]',$line);
  33. $refTab[$refNum] = $key ;
  34. ?>
  35. <tr <?php echo( $refNum %2!=0?'style="background-color:#dedede;"':'') ?> ><td><?php echo $key; ?></td><td style="width:50%;"><input style="width:100%;" type="text" name="key<?php echo $refNum ?>" <?php
  36. if($currentLang!=false){
  37. echo ' value="'.str_replace('"','&quot;',utf8_encode($value)).'" ';
  38. }
  39. ?> placeholder="<?php echo str_replace('"','&quot;',utf8_encode($value)); ?>"/></td></tr><?php
  40. $refNum++;
  41. }
  42. ?>
  43. <tr style="background-color:#000000;color:#ffffff;" ><td colspan ="2" ><input type="submit" name="Generer" value="G&eacute;nerer"></td></tr>
  44. </table>
  45. </form>
  46. <form action="#" method="POST">
  47. Langue: <input type="text" value="<?php echo $currentLang; ?>" name="lang"> <br><br>
  48. <textarea name="all">
  49. <?php
  50. foreach($template as $line){
  51. list($key,$value) = explode('[::->]',$line);
  52. echo $value;
  53. }
  54. ?>
  55. </textarea>
  56. <input type="submit" name="Generer2" value="G&eacute;nerer">
  57. </form>
  58. <?php
  59. if(isset($_['Generer'])){
  60. foreach($_ as $key=>$value){
  61. if(substr($key, 0,3)=="key"){
  62. $key = substr($key, 3);
  63. $lines[] = $refTab[$key].'[::->]'.$value;
  64. }
  65. }
  66. file_put_contents($_['lang'], implode("\n",$lines));
  67. }
  68. if(isset($_['Generer2'])){
  69. $allLines = explode("\n",$_['all']);
  70. foreach($allLines as $key=>$value){
  71. $lines[] = $refTab[$key].'[::->]'.$value;
  72. }
  73. file_put_contents($_['lang'], implode("\n",$lines));
  74. }
  75. ?>