PageRenderTime 58ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/phplist/admin/checki18n.php

https://github.com/radicaldesigns/amp
PHP | 91 lines | 75 code | 6 blank | 10 comment | 9 complexity | f386b58c4e47bfdf23eb6a1807cdcd0b MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. require_once dirname(__FILE__).'/accesscheck.php';
  3. print '<p>'.PageLink2('checki18n&amp;changedonly=yes','Show changes only').'</p>';
  4. # translation check. See that every token has a text in a file and vv
  5. function getFileI18Ntags($file) {
  6. $res = array();
  7. if (!is_file($file))
  8. return $res;
  9. $fd = fopen ($file, "r");
  10. $contents = fread ($fd, filesize ($file));
  11. fclose ($fd);
  12. preg_match_all('/\$GLOBALS\[(["|\'])I18N\1\]->get\((["|\'])([^\2]+)\2\)/Uim', $contents, $globalsi18ntags);
  13. preg_match_all('/\$I18N->get\((["|\'])([^\1]+)\1\)/Uim', $contents, $i18ntags);
  14. for ($i=0; $i< count($globalsi18ntags[0]); $i++) {
  15. array_push($res,$globalsi18ntags[3][$i]);
  16. }
  17. for ($i=0; $i< count($i18ntags[0]); $i++) {
  18. array_push($res,$i18ntags[2][$i]);
  19. }
  20. return $res;
  21. }
  22. function checkI18NDir($rootdir) {
  23. $dir = opendir($rootdir);
  24. while ($file = readdir($dir)) {
  25. $fileoutput = '';
  26. $some = 0;
  27. if (is_file($rootdir.'/'.$file)) {
  28. $fileoutput .= '<hr/><h1>'.$file."</h1><br/>";
  29. $arr = getFileI18Ntags($rootdir.'/'.$file);
  30. $lan = array();
  31. # include 'lan/en/'.$file;
  32. switch ($file) {
  33. case 'send_core.php':
  34. $_GET['page'] = 'send';break;
  35. case 'importcsv.php':
  36. $_GET['page'] = 'import2';break;
  37. default:
  38. $_GET['page'] = basename($file,'.php');
  39. }
  40. /* $page = $_GET['page'];
  41. include_once dirname(__FILE__)."/lan/".$_SESSION['adminlanguage']['iso']."/pagetitles.php";
  42. if (!strtolower($page_title) === 'phplist') {
  43. print "No page title: $page<br/>";
  44. } else {
  45. print "Page title: $page, $page_title<br/>";
  46. }
  47. */ foreach ($arr as $tag) {
  48. # $tag = ereg_replace('/','//',$tag);
  49. $translation = $GLOBALS['I18N']->get(stripslashes($tag));
  50. if (!isset($_GET['changedonly']) || ($_GET['changedonly'] === 'yes' && preg_match('/ff1717/i',$translation))) {
  51. $fileoutput .= "'".$tag.'\' =&gt; \''.$translation.'\',<br/>';
  52. $some = 1;
  53. }
  54. }
  55. if ($some) {
  56. print $fileoutput;
  57. }
  58. # print "RES: $tag<br/>";
  59. # }
  60. # if (!in_array($tag,$lan)) {
  61. # print "Missing: $tag<br/>";
  62. # } else {
  63. # print "Exists: $tag<br/>";
  64. # }
  65. # }
  66. }
  67. }
  68. }
  69. /*
  70. print '
  71. <script language="Javascript" type="text/javascript">
  72. function selectAll() {
  73. document.form.content.focus();document.form.content.select();
  74. }
  75. </script>
  76. <a href="javascript:selectAll()">Select All</a><br/>';
  77. #print '<form name="form">';
  78. print '<textarea name="content" rows="50" cols="60">';
  79. */
  80. checkI18NDir(dirname(__FILE__));
  81. checkI18NDir(dirname(__FILE__).'/commonlib/pages/');
  82. #print '</textarea>';
  83. print '</form>';