Source: filestatus.phps - download
<?php
set_time_limit(0);//avoid Maximum execution time
$projects[] = 'actionapps';
$projects[] = 'debian';
$projects[] = 'drupal';
$projects[] = 'fedora';
$projects[] = 'freedesktop';
$projects[] = 'gnome';
$projects[] = 'kde';
$projects[] = 'mandriva';
$projects[] = 'mozilla';
$projects[] = 'openoffice';
$projects[] = 'plone';
$projects[] = 'wordlist';
foreach($projects as $project){
$files = getFiles('translate/'.$project);
$data = makeTable($files);
$fp = fopen('misc/'.$project.'_status_bar.html','w');
fwrite($fp,$data);
fclose($fp);
print '<a href=misc/'.$project.'_status_bar.html>'.$project.'</a> Status Page Generated<br />';
}
//Genrate HTML page
function makeTable($files){
if(!$files[0]){
foreach($files as $dir){
$out .= makeTable($dir);
}
return($out);
}
$out = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 width="100%">
<TR bgcolor=bisque>
<TH align=left>Filename</TH>
<TH>Strings to Translate</TH>
<TH>Strings Translated (done)</TH>
<TH align=center width="20%"></TH>
<TH>%-done</TH>
</TR>';
foreach($files as $file){
$arr = getStatus($file);
$percent = @(int) (($arr[not]/$arr[count])*100);
$out .= "<tr>
<td>$arr[fn]</td>
<td>$arr[count]</td>
<td>$arr[not]</td>
<td><div style='background:green;width:$percent%'> </div></td>
<td>$percent %</td>
</tr>";
$total[count] += $arr[count];
$total[not] += $arr[not];
}
$total[percent] = @(int) (($total[not]/$total[count])*100);
$out .= "<tr bgcolor=gainsboro>
<th>Total</th>
<td>$total[count]</td>
<td>$total[not]</td>
<td><div style='background:green;width:$total[percent]%'> </div></td>
<td>$total[percent] %</td>
</tr></table><br>";
return($out);
}
//get all files in path
function getFiles($path,$sub=false){
static $data;
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if(is_file($path.'/'.$file)){
$data[$path][] = $path.'/'.$file;
}elseif($file !=='.' && $file !=='..' && $file !=='.svn'){
getFiles($path.'/'.$file,true);
}
}
if(!$sub) return($data);
}
//parse po file and retuen status
function getStatus($fn){
$data = implode('',file($fn));
$arr['not'] = $arr['count'] = 0;
//preg_match_all('/(#.+)msgid (.+)\r\nmsgstr (.+)\r\n\r\n/Us',$data,$out);
preg_match_all('/\r\nmsgstr (.+)\r\n\r\n/Us',$data,$out);
for($i=1;$i<count($out[0]);$i++){
if($out[1][$i] =='""'){
$arr['not'] +=1;
}
$arr['count'] +=1;
}
$arr['fn'] = $fn;
return($arr);
}
?>