| 1 | <?php |
|---|
| 2 | die("this script is disabled for security"); |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | error_reporting(E_ALL); |
|---|
| 22 | |
|---|
| 23 | $ret = array(); |
|---|
| 24 | $files = getFiles("../", "js$"); |
|---|
| 25 | foreach($files as $file) { |
|---|
| 26 | $fp = fopen($file, "r"); |
|---|
| 27 | $data = ""; |
|---|
| 28 | while(!feof($fp)) { |
|---|
| 29 | $data .= fread($fp, 1024); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | preg_match_all('#_lc\("([^"]+)"\)|_lc\(\'([^\']+)\'\)#', $data, $m); |
|---|
| 33 | foreach($m[1] as $i) { |
|---|
| 34 | if(trim($i)=="") continue; |
|---|
| 35 | $ret[] = $i; |
|---|
| 36 | } |
|---|
| 37 | foreach($m[2] as $i) { |
|---|
| 38 | if(trim($i)=="") continue; |
|---|
| 39 | $ret[] = $i; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | if(eregi('htmlarea\\.js$', $file)) { |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | preg_match_all('#[a-z]+: *\[ * "([^"]+)"#', $data, $m); |
|---|
| 46 | foreach($m[1] as $i) { |
|---|
| 47 | if(trim($i)=="") continue; |
|---|
| 48 | $ret[] = $i; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | preg_match_all('#HTMLArea\\._lc\\({key: \'([^\']*)\'#', $data, $m); |
|---|
| 53 | foreach($m[1] as $i) { |
|---|
| 54 | if(trim($i)=="") continue; |
|---|
| 55 | $ret[] = $i; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | $data = substr($data, strpos($data, "this.fontname = {"), strpos($data, "this.customSelects = {};")-strpos($data, "this.fontname = {")); |
|---|
| 60 | preg_match_all('#"([^"]+)"[ \t]*:[ \t]*["\'][^"\']*["\'],?#', $data, $m); |
|---|
| 61 | foreach($m[1] as $i) { |
|---|
| 62 | if(trim($i)=="") continue; |
|---|
| 63 | $ret[] = $i; |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | $files = getFiles("../popups/", "html$"); |
|---|
| 69 | foreach($files as $file) |
|---|
| 70 | { |
|---|
| 71 | if(preg_match("#custom2.html$#", $file)) continue; |
|---|
| 72 | if(preg_match('#old_#', $file)) continue; |
|---|
| 73 | $ret = array_merge($ret, parseHtmlFile($file)); |
|---|
| 74 | } |
|---|
| 75 | $ret = array_unique($ret); |
|---|
| 76 | $langData['HTMLArea'] = $ret; |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | $plugins = getFiles("../plugins/"); |
|---|
| 81 | foreach($plugins as $pluginDir) { |
|---|
| 82 | $plugin = substr($pluginDir, 12); |
|---|
| 83 | if($plugin=="ibrowser") continue; |
|---|
| 84 | $ret = array(); |
|---|
| 85 | |
|---|
| 86 | $files = getFiles("$pluginDir/", "js$"); |
|---|
| 87 | $files = array_merge($files, getFiles("$pluginDir/popups/", "html$")); |
|---|
| 88 | $files = array_merge($files, getFiles("$pluginDir/", "php$")); |
|---|
| 89 | foreach($files as $file) |
|---|
| 90 | { |
|---|
| 91 | $fp = fopen($file, "r"); |
|---|
| 92 | $data = ""; |
|---|
| 93 | if($fp) { |
|---|
| 94 | echo "$file open...<br>"; |
|---|
| 95 | while(!feof($fp)) { |
|---|
| 96 | $data .= fread($fp, 1024); |
|---|
| 97 | } |
|---|
| 98 | preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); |
|---|
| 99 | foreach($m[1] as $i) { |
|---|
| 100 | if(trim(strip_tags($i))=="") continue; |
|---|
| 101 | $ret[] = $i; |
|---|
| 102 | } |
|---|
| 103 | foreach($m[2] as $i) { |
|---|
| 104 | if(trim(strip_tags($i))=="") continue; |
|---|
| 105 | $ret[] = $i; |
|---|
| 106 | } |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | if($plugin=="TableOperations") |
|---|
| 111 | { |
|---|
| 112 | preg_match_all('#options = \\[([^\\]]+)\\];#', $data, $m); |
|---|
| 113 | foreach($m[1] as $i) { |
|---|
| 114 | preg_match_all('#"([^"]+)"#', $i, $m1); |
|---|
| 115 | foreach($m1[1] as $i) { |
|---|
| 116 | $ret[] = $i; |
|---|
| 117 | } |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | preg_match_all('#\\["[^"]+",[ \t]*"[^"]+",[ \t]*"([^"]+)"\\]#', $data, $m); |
|---|
| 122 | foreach($m[1] as $i) { |
|---|
| 123 | $ret[] = $i; |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | $files = getFiles("$pluginDir/", "html$"); |
|---|
| 129 | $files = array_merge($files, getFiles("$pluginDir/", "php$")); |
|---|
| 130 | foreach($files as $file) |
|---|
| 131 | { |
|---|
| 132 | $ret = array_merge($ret, parseHtmlFile($file, $plugin)); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | $files = getFiles("$pluginDir/popups/", "html$"); |
|---|
| 136 | foreach($files as $file) |
|---|
| 137 | { |
|---|
| 138 | $ret = array_merge($ret, parseHtmlFile($file, $plugin)); |
|---|
| 139 | } |
|---|
| 140 | $ret = array_unique($ret); |
|---|
| 141 | |
|---|
| 142 | $langData[$plugin] = $ret; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | $plugins = getFiles("../modules/"); |
|---|
| 146 | foreach($plugins as $pluginDir) { |
|---|
| 147 | $plugin = substr($pluginDir, 12); |
|---|
| 148 | $ret = array(); |
|---|
| 149 | $files = getFiles("$pluginDir/", "js$"); |
|---|
| 150 | foreach($files as $file) |
|---|
| 151 | { |
|---|
| 152 | $fp = fopen($file, "r"); |
|---|
| 153 | $data = ""; |
|---|
| 154 | if($fp) { |
|---|
| 155 | echo "$file open...<br>"; |
|---|
| 156 | while(!feof($fp)) { |
|---|
| 157 | $data .= fread($fp, 1024); |
|---|
| 158 | } |
|---|
| 159 | preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); |
|---|
| 160 | foreach($m[1] as $i) { |
|---|
| 161 | if(trim(strip_tags($i))=="") continue; |
|---|
| 162 | $ret[] = $i; |
|---|
| 163 | } |
|---|
| 164 | foreach($m[2] as $i) { |
|---|
| 165 | if(trim(strip_tags($i))=="") continue; |
|---|
| 166 | $ret[] = $i; |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | } |
|---|
| 170 | $ret = array_unique($ret); |
|---|
| 171 | $langData[$plugin] = $ret; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | foreach($langData as $plugin=>$strings) { |
|---|
| 176 | if(sizeof($strings)==0) continue; |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | $data = "// I18N constants\n"; |
|---|
| 180 | $data .= "//\n"; |
|---|
| 181 | $data .= "// LANG: \"base\", ENCODING: UTF-8\n"; |
|---|
| 182 | $data .= "// Author: Translator-Name, <email@example.com>\n"; |
|---|
| 183 | $data .= "//\n"; |
|---|
| 184 | $data .= "// Last revision: 06 september 2007\n"; |
|---|
| 185 | $data .= "// Please don´t remove this information\n"; |
|---|
| 186 | $data .= "// If you modify any source, please insert a comment with your name and e-mail\n"; |
|---|
| 187 | $data .= "//\n"; |
|---|
| 188 | $data .= "// Distributed under the same terms as HTMLArea itself.\n"; |
|---|
| 189 | $data .= "// This notice MUST stay intact for use (see license.txt).\n"; |
|---|
| 190 | $data .= "//\n"; |
|---|
| 191 | $data .= "// (Please, remove information below)\n"; |
|---|
| 192 | $data .= "// FOR TRANSLATORS:\n"; |
|---|
| 193 | $data .= "//\n"; |
|---|
| 194 | $data .= "// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE\n"; |
|---|
| 195 | $data .= "// (at least a valid email address)\n"; |
|---|
| 196 | $data .= "//\n"; |
|---|
| 197 | $data .= "// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;\n"; |
|---|
| 198 | $data .= "// (if this is not possible, please include a comment\n"; |
|---|
| 199 | $data .= "// that states what encoding is necessary.)\n"; |
|---|
| 200 | $data .= "\n"; |
|---|
| 201 | $data .= "{\n"; |
|---|
| 202 | sort($strings); |
|---|
| 203 | foreach($strings as $string) { |
|---|
| 204 | $string = str_replace(array('\\', '"'), array('\\\\', '\\"'), $string); |
|---|
| 205 | $data .= " \"".$string."\": \"\",\n"; |
|---|
| 206 | } |
|---|
| 207 | $data = substr($data, 0, -2); |
|---|
| 208 | $data .= "\n"; |
|---|
| 209 | $data .= "}\n"; |
|---|
| 210 | |
|---|
| 211 | if($plugin=="HTMLArea") { |
|---|
| 212 | $file = "../lang/base.js"; |
|---|
| 213 | $fp = fopen($file, "w"); |
|---|
| 214 | if(!$fp) continue; |
|---|
| 215 | fwrite($fp, $data); |
|---|
| 216 | fclose($fp); |
|---|
| 217 | echo "$file written...<br>"; |
|---|
| 218 | } elseif (($plugin=="InternetExplorer")||($plugin=="InsertTable")||($plugin=="InsertImage")||($plugin=="GetHtml")||($plugin=="Gecko")||($plugin=="Dialogs")||($plugin=="CreateLink")||($plugin=="ColorPicker")) { |
|---|
| 219 | $file = "../modules/$plugin/lang/base.js"; |
|---|
| 220 | $fp = fopen($file, "w"); |
|---|
| 221 | if(!$fp) continue; |
|---|
| 222 | fwrite($fp, $data); |
|---|
| 223 | fclose($fp); |
|---|
| 224 | echo "$file written...<br>"; |
|---|
| 225 | } elseif ($plugin=="FullScreen") { |
|---|
| 226 | $file = "../modules/$plugin/lang/base.js"; |
|---|
| 227 | $fp = fopen($file, "w"); |
|---|
| 228 | if(!$fp) continue; |
|---|
| 229 | fwrite($fp, $data); |
|---|
| 230 | fclose($fp); |
|---|
| 231 | echo "$file written...<br>"; |
|---|
| 232 | $file = "../plugins/$plugin/lang/base.js"; |
|---|
| 233 | $fp = fopen($file, "w"); |
|---|
| 234 | if(!$fp) continue; |
|---|
| 235 | fwrite($fp, $data); |
|---|
| 236 | fclose($fp); |
|---|
| 237 | echo "$file written...<br>"; |
|---|
| 238 | } else { |
|---|
| 239 | $file = "../plugins/$plugin/lang/base.js"; |
|---|
| 240 | $fp = fopen($file, "w"); |
|---|
| 241 | if(!$fp) continue; |
|---|
| 242 | fwrite($fp, $data); |
|---|
| 243 | fclose($fp); |
|---|
| 244 | echo "$file written...<br>"; |
|---|
| 245 | } |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | function parseHtmlFile($file, $plugin="") |
|---|
| 252 | { |
|---|
| 253 | $ret = array(); |
|---|
| 254 | |
|---|
| 255 | $fp = fopen($file, "r"); |
|---|
| 256 | if(!$fp) { |
|---|
| 257 | die("invalid fp"); |
|---|
| 258 | } |
|---|
| 259 | $data = ""; |
|---|
| 260 | while(!feof($fp)) { |
|---|
| 261 | $data .= fread($fp, 1024); |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") { |
|---|
| 265 | |
|---|
| 266 | $elems = array("l10n"); |
|---|
| 267 | } else { |
|---|
| 268 | $elems = array("title", "input", "select", "legend", "span", "option", "td", "button", "div", "label"); |
|---|
| 269 | } |
|---|
| 270 | foreach($elems as $elem) { |
|---|
| 271 | preg_match_all("#<{$elem}[^>]*>([^<^\"]+)</$elem>#i", $data, $m); |
|---|
| 272 | foreach($m[1] as $i) { |
|---|
| 273 | if(trim(strip_tags($i))=="") continue; |
|---|
| 274 | if($i=="/") continue; |
|---|
| 275 | if($plugin=="ImageManager" && preg_match('#^--+$#', $i)) continue; |
|---|
| 276 | if($plugin=="CharacterMap" && preg_match('#&[a-z0-9]+;#i', trim($i)) || $i=="@") continue; |
|---|
| 277 | if($plugin=="SpellChecker" && preg_match('#^\'\\.\\$[a-z]+\\.\'$#', $i)) continue; |
|---|
| 278 | $ret[] = trim($i); |
|---|
| 279 | } |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") |
|---|
| 283 | { |
|---|
| 284 | |
|---|
| 285 | preg_match_all('#"_\(([^"]+)\)"#i', $data, $m); |
|---|
| 286 | foreach($m[1] as $i) { |
|---|
| 287 | if(trim($i)=="") continue; |
|---|
| 288 | $ret[] = $i; |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | else |
|---|
| 292 | { |
|---|
| 293 | preg_match_all('#title="([^"]+)"#i', $data, $m); |
|---|
| 294 | foreach($m[1] as $i) { |
|---|
| 295 | if(trim(strip_tags($i))=="") continue; |
|---|
| 296 | if(strip_tags($i)==" - ") continue; |
|---|
| 297 | $ret[] = $i; |
|---|
| 298 | } |
|---|
| 299 | } |
|---|
| 300 | return($ret); |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | function getFiles($rootdirpath, $eregi_match='') { |
|---|
| 305 | $array = array(); |
|---|
| 306 | if ($dir = @opendir($rootdirpath)) { |
|---|
| 307 | $array = array(); |
|---|
| 308 | while (($file = readdir($dir)) !== false) { |
|---|
| 309 | if($file=="." || $file==".." || $file==".svn") continue; |
|---|
| 310 | if($eregi_match=="") |
|---|
| 311 | $array[] = $rootdirpath."/".$file; |
|---|
| 312 | else if(eregi($eregi_match,$file)) |
|---|
| 313 | $array[] = $rootdirpath."/".$file; |
|---|
| 314 | |
|---|
| 315 | } |
|---|
| 316 | closedir($dir); |
|---|
| 317 | } |
|---|
| 318 | return $array; |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | ?> |
|---|