/phplist/admin/checki18n.php
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
- <?php
- require_once dirname(__FILE__).'/accesscheck.php';
- print '<p>'.PageLink2('checki18n&changedonly=yes','Show changes only').'</p>';
- # translation check. See that every token has a text in a file and vv
- function getFileI18Ntags($file) {
- $res = array();
- if (!is_file($file))
- return $res;
- $fd = fopen ($file, "r");
- $contents = fread ($fd, filesize ($file));
- fclose ($fd);
- preg_match_all('/\$GLOBALS\[(["|\'])I18N\1\]->get\((["|\'])([^\2]+)\2\)/Uim', $contents, $globalsi18ntags);
- preg_match_all('/\$I18N->get\((["|\'])([^\1]+)\1\)/Uim', $contents, $i18ntags);
- for ($i=0; $i< count($globalsi18ntags[0]); $i++) {
- array_push($res,$globalsi18ntags[3][$i]);
- }
- for ($i=0; $i< count($i18ntags[0]); $i++) {
- array_push($res,$i18ntags[2][$i]);
- }
- return $res;
- }
- function checkI18NDir($rootdir) {
- $dir = opendir($rootdir);
- while ($file = readdir($dir)) {
- $fileoutput = '';
- $some = 0;
- if (is_file($rootdir.'/'.$file)) {
- $fileoutput .= '<hr/><h1>'.$file."</h1><br/>";
- $arr = getFileI18Ntags($rootdir.'/'.$file);
- $lan = array();
- # include 'lan/en/'.$file;
- switch ($file) {
- case 'send_core.php':
- $_GET['page'] = 'send';break;
- case 'importcsv.php':
- $_GET['page'] = 'import2';break;
- default:
- $_GET['page'] = basename($file,'.php');
- }
- /* $page = $_GET['page'];
- include_once dirname(__FILE__)."/lan/".$_SESSION['adminlanguage']['iso']."/pagetitles.php";
- if (!strtolower($page_title) === 'phplist') {
- print "No page title: $page<br/>";
- } else {
- print "Page title: $page, $page_title<br/>";
- }
- */ foreach ($arr as $tag) {
- # $tag = ereg_replace('/','//',$tag);
- $translation = $GLOBALS['I18N']->get(stripslashes($tag));
- if (!isset($_GET['changedonly']) || ($_GET['changedonly'] === 'yes' && preg_match('/ff1717/i',$translation))) {
- $fileoutput .= "'".$tag.'\' => \''.$translation.'\',<br/>';
- $some = 1;
- }
- }
- if ($some) {
- print $fileoutput;
- }
- # print "RES: $tag<br/>";
- # }
- # if (!in_array($tag,$lan)) {
- # print "Missing: $tag<br/>";
- # } else {
- # print "Exists: $tag<br/>";
- # }
- # }
- }
- }
- }
- /*
- print '
- <script language="Javascript" type="text/javascript">
- function selectAll() {
- document.form.content.focus();document.form.content.select();
- }
- </script>
- <a href="javascript:selectAll()">Select All</a><br/>';
- #print '<form name="form">';
- print '<textarea name="content" rows="50" cols="60">';
- */
- checkI18NDir(dirname(__FILE__));
- checkI18NDir(dirname(__FILE__).'/commonlib/pages/');
- #print '</textarea>';
- print '</form>';