"; while(!feof($fp)) { $data .= fread($fp, 1024); } preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } foreach($m[2] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } } } if($plugin=="TableOperations") { preg_match_all('#options = \\[([^\\]]+)\\];#', $data, $m); foreach($m[1] as $i) { preg_match_all('#"([^"]+)"#', $i, $m1); foreach($m1[1] as $i) { $ret[] = $i; } } //["cell-delete", "td", "Delete cell"], preg_match_all('#\\["[^"]+",[ \t]*"[^"]+",[ \t]*"([^"]+)"\\]#', $data, $m); foreach($m[1] as $i) { $ret[] = $i; } } $files = getFiles("$pluginDir/", "html$"); $files = array_merge($files, getFiles("$pluginDir/", "php$")); foreach($files as $file) { $ret = array_merge($ret, parseHtmlFile($file, $plugin)); } $files = getFiles("$pluginDir/popups/", "html$"); foreach($files as $file) { $ret = array_merge($ret, parseHtmlFile($file, $plugin)); } $ret = array_unique($ret); $langData[$plugin] = $ret; } $plugins = getFiles("../modules/"); foreach($plugins as $pluginDir) { $plugin = substr($pluginDir, 12); $ret = array(); $files = getFiles("$pluginDir/", "js$"); foreach($files as $file) { $fp = fopen($file, "r"); $data = ""; if($fp) { echo "$file open...
"; while(!feof($fp)) { $data .= fread($fp, 1024); } preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } foreach($m[2] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } } } $ret = array_unique($ret); $langData[$plugin] = $ret; } foreach($langData as $plugin=>$strings) { if(sizeof($strings)==0) continue; $data = "// I18N constants\n"; $data .= "//\n"; $data .= "// LANG: \"base\", ENCODING: UTF-8\n"; $data .= "// Author: Translator-Name, \n"; $data .= "//\n"; $data .= "// Last revision: 06 september 2007\n"; $data .= "// Please don´t remove this information\n"; $data .= "// If you modify any source, please insert a comment with your name and e-mail\n"; $data .= "//\n"; $data .= "// Distributed under the same terms as HTMLArea itself.\n"; $data .= "// This notice MUST stay intact for use (see license.txt).\n"; $data .= "//\n"; $data .= "// (Please, remove information below)\n"; $data .= "// FOR TRANSLATORS:\n"; $data .= "//\n"; $data .= "// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE\n"; $data .= "// (at least a valid email address)\n"; $data .= "//\n"; $data .= "// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;\n"; $data .= "// (if this is not possible, please include a comment\n"; $data .= "// that states what encoding is necessary.)\n"; $data .= "\n"; $data .= "{\n"; sort($strings); foreach($strings as $string) { $string = str_replace(array('\\', '"'), array('\\\\', '\\"'), $string); $data .= " \"".$string."\": \"\",\n"; } $data = substr($data, 0, -2); $data .= "\n"; $data .= "}\n"; if($plugin=="HTMLArea") { $file = "../lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...
"; } elseif (($plugin=="InternetExplorer")||($plugin=="InsertTable")||($plugin=="InsertImage")||($plugin=="GetHtml")||($plugin=="Gecko")||($plugin=="Dialogs")||($plugin=="CreateLink")||($plugin=="ColorPicker")) { $file = "../modules/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...
"; } elseif ($plugin=="FullScreen") { $file = "../modules/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...
"; $file = "../plugins/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...
"; } else { $file = "../plugins/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...
"; } } function parseHtmlFile($file, $plugin="") { $ret = array(); $fp = fopen($file, "r"); if(!$fp) { die("invalid fp"); } $data = ""; while(!feof($fp)) { $data .= fread($fp, 1024); } if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") { //-tags for inline-dialog or panel-dialog based dialogs $elems = array("l10n"); } else { $elems = array("title", "input", "select", "legend", "span", "option", "td", "button", "div", "label"); } foreach($elems as $elem) { preg_match_all("#<{$elem}[^>]*>([^<^\"]+)#i", $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; if($i=="/") continue; if($plugin=="ImageManager" && preg_match('#^--+$#', $i)) continue; //skip those ------ if($plugin=="CharacterMap" && preg_match('#&[a-z0-9]+;#i', trim($i)) || $i=="@") continue; if($plugin=="SpellChecker" && preg_match('#^\'\\.\\$[a-z]+\\.\'$#', $i)) continue; $ret[] = trim($i); } } if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") { //_( for inline-dialog or panel-dialog based dialogs preg_match_all('#"_\(([^"]+)\)"#i', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } } else { preg_match_all('#title="([^"]+)"#i', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; if(strip_tags($i)==" - ") continue; //skip those - (ImageManager) $ret[] = $i; } } return($ret); } function getFiles($rootdirpath, $eregi_match='') { $array = array(); if ($dir = @opendir($rootdirpath)) { $array = array(); while (($file = readdir($dir)) !== false) { if($file=="." || $file==".." || $file==".svn") continue; if($eregi_match=="") $array[] = $rootdirpath."/".$file; else if(eregi($eregi_match,$file)) $array[] = $rootdirpath."/".$file; } closedir($dir); } return $array; } ?>