Index: trunk/tools/phrase_locator.php =================================================================== diff -u -N -r912 -r1852 --- trunk/tools/phrase_locator.php (.../phrase_locator.php) (revision 912) +++ trunk/tools/phrase_locator.php (.../phrase_locator.php) (revision 1852) @@ -1,50 +1,23 @@ GetCol($sql); + $db_phrases = $tool_db->GetCol($sql); foreach ($db_phrases as $phrase) { unset($phrases[$phrase]); // phrase is translated + if( !isset($phrase_files[$phrase]) ) + { + unset($phrase_files[$phrase]); + } + else + { + echo 'inconsistance in phrase '.$phrase.'
'; + } } $ret = Array(); @@ -54,6 +27,7 @@ } tool_printPre($ret); + tool_printPre($phrase_files); if( unlink(BASE_PATH.'/new_phrases.txt') ) { @@ -68,4 +42,48 @@ { die('Can\'t create file new_phrases.txt'); } + + + function addPhrase($array, $file) + { + global $phrases, $phrase_files; + + foreach ($array as $phrase_name) + { + $phrase_name = strtolower($phrase_name); + $phrases[$phrase_name] = 1; + if( !isset($phrase_files[$phrase_name]) ) $phrase_files[$phrase_name] = Array(); + $phrase_files[$phrase_name][] = substr($file, strlen(BASE_PATH), strlen($file) ); + } + } + + function scanDir($FolderPath) + { + $scan_types = Array('php','js','tpl'); + $FolderHandle = opendir($FolderPath); + if($FolderHandle) + { + while( false !== ($file = readdir($FolderHandle)) ) + { + if($file == '.' || $file == '..') continue; + $file = $FolderPath.$file; + + if( is_dir($file) ) + { + scanDir($file.'/'); + } + elseif( is_file($file) && in_array(substr($file,-3),$scan_types) ) + { + $filedata = file_get_contents($file); + + preg_match_all('/\'(lu_.*|la_.*)\'/U',$filedata,$rets); + if($rets[1]) addPhrase($rets[1], $file); + + preg_match_all('/"(lu_.*|la_.*)"/U',$filedata,$rets); + if($rets[1]) addPhrase($rets[1], $file); + } + } + closedir($FolderHandle); + } + } ?> \ No newline at end of file