Ticket #203 (closed defect: fixed)
_lc(...) language .js scanner
| Reported by: | kim@… | Owned by: | niko |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Language | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I put together a little PHP script that scans through the plugin folder and parses all the .js files for _lc(...) entries and generate a report. This can be usefull for tracking changes in the plugins for new language strings. The catch for this to work is that all entries are present in the .js files and that it matches _lc("...")
The php file should be stored in the plugins folder, and is ready to run - no configuring is needed.
Filename : lc_strings_report.php
<?php
/* Quick system for analyzing the files for _lc occurencies.
All pluginfolders are scanned for .js files, and the .js
files are then parsed for _lc() occurencies and listed.
Credits : Kim Steinhaug, kim@steinhaug.com
Version v1.0
*/
function retrieveDirs($rootdirpath,$eregi_match='') {
if ($dir = @opendir($rootdirpath)) {
$array = array();
while (($file = readdir($dir)) !== false) {
if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..") {
if(!$eregi_match){
$array[] = $file;
} else {
if(eregi($eregi_match,$file))
$array[] = $file;
}
} else if($eregi_match && $file != "." && $file != ".."){
if(eregi($eregi_match,$file))
$array[] = $file;
}
}
closedir($dir);
}
return $array;
}
function get_lc_array($data){
$temp = explode('_lc(',$data);
$return = array();
foreach ($temp AS $value){
if(substr($value,0,6)=='string'){
} else if(substr($value,0,1)=='"'){
$temp2 = explode('")',$value);
$var = substr($temp2[0],1);
if(ereg('"',$var)){
$temp3 = explode('"',$var);
$var = $temp3[0];
} else {
}
array_push($return,$var);
}
}
return $return;
}
echo '<em>Brief explernation, scans through all folders and parses all .js files for _lc(...) entries and lists them.</em>';
$path = str_replace('lc_strings_report.php','',$_SERVER["SCRIPT_FILENAME"]);
$dirs = retrieveDirs($path);
foreach ($dirs AS $dir){
echo '<h3>' . $dir . '</h3>';
$jsfiles = retrieveDirs($path . '/' . $dir . '/','js');
if(is_array($jsfiles) && count($jsfiles)){
foreach ($jsfiles AS $filename){
$data = file_get_contents($path . '/' . $dir . '/' . $filename);
$lc = get_lc_array($data);
foreach ($lc AS $lc_var){
echo ' "' . $lc_var . '"' . "<br>\r\n";
}
}
}
}
?>
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
