fixed translation stats for wescamp

This commit is contained in:
Ben Anderman 2008-04-13 19:40:38 +00:00
parent 4f240f1258
commit 03d95cc793
5 changed files with 98 additions and 126 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
SVNCHECKOUTPATH=/public/vhost/w/wesnoth/source
SVNCHECKOUTPATH=/home/ben/public_html/wesnoth/gettext/source
echo update started at `date` >> ~/g.w.o-updates.log
@ -19,6 +19,6 @@ svn up
#svn up
#update the stats
cd ~/html/gettext/
cd ~/public_html/wesnoth/gettext/
php grab-stats.php >> ~/g.w.o-updates.log
echo update completed at `date` >> ~/g.w.o-updates.log

View File

@ -13,29 +13,41 @@ $msgfmt="/usr/bin/msgfmt";
$branch="1.4";
$trunkbasedir="/public/vhost/w/wesnoth/source/trunk/";
$branchbasedir="/public/vhost/w/wesnoth/source/" . $branch . "/";
//$extrabasedir="/public/vhost/w/wesnoth/source/wescamp-i18n/";
$branchbasedir="/public/vhost/w/wesnoth/source/$branch/";
$extratbasedir="/public/vhost/w/wesnoth/source/wescamp-i18n/trunk/"; //trunk
$extrabbasedir="/public/vhost/w/wesnoth/source/wescamp-i18n/branches/$branch/"; //branch
//$packages = file_get_contents($basedir . "/po/DOMAINS");
//$packages = substr($packages, 0, strlen($packages)-1);
$corepackages = "wesnoth wesnoth-lib wesnoth-units wesnoth-multiplayer wesnoth-httt wesnoth-tutorial";
//$packages = trim(system("grep ^SUBDIRS " . $basedir . "/po/Makefile.am | cut -d= -f2"));
$packages = "wesnoth wesnoth-lib wesnoth-editor wesnoth-units wesnoth-multiplayer wesnoth-anl wesnoth-tutorial wesnoth-manpages wesnoth-manual wesnoth-aoi wesnoth-did wesnoth-ei wesnoth-httt wesnoth-l wesnoth-nr wesnoth-sof wesnoth-sotbe wesnoth-tb wesnoth-thot wesnoth-trow wesnoth-tsg wesnoth-utbs";
$packages = "wesnoth wesnoth-lib wesnoth-editor wesnoth-units wesnoth-multiplayer wesnoth-tutorial wesnoth-manpages wesnoth-manual wesnoth-aoi wesnoth-did wesnoth-ei wesnoth-httt wesnoth-l wesnoth-nr wesnoth-sof wesnoth-sotbe wesnoth-tb wesnoth-thot wesnoth-trow wesnoth-tsg wesnoth-utbs";
//get unofficial packages
// TODO:
// reactivate when stuff adjusted for new infrastructure
// deactivated for not
//$dir = opendir($extrabasedir);
//
//$extra_packages = "";
//while (false !== ($file = readdir($dir))) {
// if($file[0] != '.'){
// $packarray[] = $file;
// }
//}
//sort($packarray);
//$extrapackages = implode(" ", $packarray);
//trunk
$packarray = array();
$dir = opendir($extratbasedir); //trunk
while (false !== ($file = readdir($dir))) {
if($file[0] != '.'){
$packarray[] = $file;
}
}
closedir($dir);
sort($packarray);
$extratpackages = implode(" ", $packarray);
//branch
$packarray = array();
$dir = opendir($extrabbasedir); //branch
while (false !== ($file = readdir($dir))) {
if($file[0] != '.'){
$packarray[] = $file;
}
}
closedir($dir);
sort($packarray);
$extrabpackages = implode(" ", $packarray);
//$languages = file_get_contents($basedir . "/po/LINGUAS");

View File

@ -27,80 +27,58 @@ $currdate = date("Y-m-d",mktime());
}
$packs = explode(" ", $packages);
$extrapacks = explode(" ", $extrapackages);
$extratpacks = explode(" ", $extratpackages);
$extrabpacks = explode(" ", $extrabpackages);
echo "<h1>Getting stats for trunk</h1>";
function grab_stats ($tob, $official, $packs) // trunk or branch, official (1) or extras (0), package array
{
//these are defined in config.php
global $trunkbasedir;
global $branchbasedir;
global $extratbasedir;
global $extrabbasedir;
#Get trunk stats
foreach($packs as $package){
$stats = array();
$languages = file_get_contents($trunkbasedir . "/po/" . $package . "/LINGUAS");
$languages = substr($languages, 0, strlen($languages)-1);
$langs = explode(" ", $languages);
echo "<h2>Getting stats for package $package</h2>";
$stats["_pot"]=getstats($trunkbasedir . "/po/" . $package . "/" . $package . ".pot");
if(!file_exists("stats/" . $package)){
system("mkdir stats/" . $package);
foreach($packs as $package){
$stats = array();
if ($official)
{
$basedir = ($tob == "trunk") ? $trunkbasedir : $branchbasedir;
$po_dir = $basedir . "/po/" . $package . "/";
$domain = $package;
} else { // wescamp
$basedir = ($tob == "trunk") ? $extratbasedir : $extrabbasedir;
$po_dir = $basedir . "/" . $package . "/po/";
$domain = getdomain($package);
}
$languages = file_get_contents($po_dir . "/LINGUAS");
$languages = substr($languages, 0, strlen($languages)-1);
$langs = explode(" ", $languages);
echo "<h2>Getting stats for package $package</h2>";
$stats["_pot"] = getstats("$po_dir/" . $domain . ".pot");
if (!file_exists("stats/" . $domain))
{
system("mkdir stats/" . $domain);
}
foreach ($langs as $lang)
{
echo "Getting stats for lang $lang<br/>";
$pofile = $po_dir . "/" . $lang . ".po";
$stats[$lang] = getstats($pofile);
}
$serialized = serialize($stats);
$file = fopen("stats/" . $domain . "/" . $tob . "stats", "wb");
fwrite($file, $serialized);
fclose($file);
}
foreach($langs as $lang){
echo "Getting stats for lang $lang<br/>";
$pofile = $trunkbasedir . "/po/" . $package . "/" . $lang . ".po";
$stats[$lang]=getstats($pofile);
}
$serialized = serialize($stats);
$file = fopen("stats/" . $package . "/trunkstats", "wb");
fwrite($file, $serialized);
fclose($file);
}
echo "<h1>Getting stats for branch</h1>";
echo "<h1>Getting stats for trunk</h1>\n";
grab_stats("trunk", 1, $packs);
grab_stats("trunk", 0, $extratpacks);
#Get branch stats
foreach($packs as $package){
$stats = array();
$languages = file_get_contents($branchbasedir . "/po/" . $package . "/LINGUAS");
$languages = substr($languages, 0, strlen($languages)-1);
$langs = explode(" ", $languages);
echo "<h2>Getting stats for package $package</h2>";
$stats["_pot"]=getstats($branchbasedir . "/po/" . $package . "/" . $package . ".pot");
if(!file_exists("stats/" . $package)){
system("mkdir stats/" . $package);
}
foreach($langs as $lang){
echo "Getting stats for lang $lang<br/>";
$pofile = $branchbasedir . "/po/" . $package . "/" . $lang . ".po";
$stats[$lang]=getstats($pofile);
}
echo "<h1>Getting stats for branch ($branch)</h1>\n";
grab_stats("branch", 1, $packs);
grab_stats("branch", 0, $extrabpacks);
$serialized = serialize($stats);
$file = fopen("stats/" . $package . "/branchstats", "wb");
fwrite($file, $serialized);
fclose($file);
}
// TODO:
// Adjust wescamp stats to work nicely with the new server interface
// deactivated for the moment
//foreach($extrapacks as $package){
// $stats = array();
// $domain = getdomain($package);
// $languages = file_get_contents($extrabasedir . "/" . $package . "/po/LINGUAS");
// $languages = substr($languages, 0, strlen($languages)-1);
// $langs = explode(" ", $languages);
// echo "<h2>Getting stats for package $package</h2>";
// $stats["_pot"]=getstats($extrabasedir . "/" . $package . "/po/" . $domain . ".pot");
// if(!file_exists("stats/" . $domain)){
// system("mkdir stats/" . $domain);
// }
// foreach($langs as $lang){
// echo "Getting stats for lang $lang<br/>";
// $pofile = $extrabasedir . "/" . $package . "/po/" . $lang . ".po";
// $stats[$lang]=getstats($pofile);
// }
// $serialized = serialize($stats);
// $file = fopen("stats/" . $domain . "/stats", "wb");
// fwrite($file, $serialized);
// fclose($file);
//}
?>

View File

@ -23,7 +23,8 @@ function cmp_alpha($a, $b){
$existing_packs = explode(" ", $packages);
$existing_corepacks = explode(" ", $corepackages);
$existing_extra_packs = explode(" ", $extrapackages);
$existing_extra_packs_t = explode(" ", $extratpackages);
$existing_extra_packs_b = explode(" ", $extrabpackages);
$stats = array();
if(!isset($_GET['version'])){
@ -44,15 +45,11 @@ if($lang != "") {
if($i==0){
$packs = $existing_packs;
}else{
$packs = $existing_extra_packs;
$packs = ($version == 'trunk') ? $existing_extra_packs_t : $existing_extra_packs_b;
}
foreach($packs as $pack){
if($i==1){
$pack = getdomain($pack);
$statsfile = "stats";
} else {
$statsfile = $version . "stats";
}
if($i==1) $pack = getdomain($pack);
$statsfile = $version . "stats";
if (!file_exists("stats/" . $pack . "/" . $statsfile)) {
continue;
}
@ -78,11 +75,7 @@ if($lang != "") {
unset($lang);
}
$firstpack = $existing_packs[0];
if(in_array($firstpack,$existing_packs)){
$statsfile = $version . "stats";
} else {
$statsfile = "stats";
}
$statsfile = $version . "stats";
$filestat = stat("stats/" . $firstpack . "/" . $statsfile);
$date = $filestat[9];
?>
@ -130,7 +123,6 @@ Version:
<? }else{ ?>
<a href="?version=trunk&amp;package=<?=$package?>&amp;lang=<?=$lang?>">Development</a> || <strong><?=$branch?></strong>
<? } ?>
(only meaningful for official packs)
</td>
</tr>
<tr>
@ -220,7 +212,8 @@ foreach($stats as $stat){
}
echo "<strong><a href='http://svn.gna.org/viewcvs/*checkout*/wesnoth/$repo/po/" . $stat[4]. "/" . $lang . ".po'>" . $stat[4] . "</a></strong>";
}else{
echo "<strong><a href='http://svn.berlios.de/viewcvs/*checkout*/wescamp-i18n/" . getpackage($stat[4]) . "/po/" . $lang . ".po'>" . $stat[4] . "</a></strong>";
$repo = ($version == 'trunk') ? 'trunk' : "branches/$branch";
echo "<strong><a href='http://svn.berlios.de/viewcvs/*checkout*/wescamp-i18n/$repo/" . getpackage($stat[4]) . "/po/" . $lang . ".po'>" . $stat[4] . "</a></strong>";
}
?>

View File

@ -24,7 +24,8 @@ $official = true;
$existing_packs = explode(" ", $packages);
$existing_corepacks = explode(" ", $corepackages);
$existing_extra_packs = explode(" ", $extrapackages);
$existing_extra_packs_t = explode(" ", $extratpackages);
$existing_extra_packs_b = explode(" ", $extrabpackages);
$firstpack = $existing_packs[0];
$stats = array();
if(!isset($_GET['package'])){
@ -83,17 +84,13 @@ if($package=='alloff' || $package == 'allcore'){
if($i==0){
$packs = $existing_packs;
}else{
$packs = $existing_extra_packs;
$packs = ($version == 'trunk') ? $existing_extra_packs_t : $existing_extra_packs_b;
}
foreach($packs as $pack){
if($i == 0) {
if($version == 'branch') {
$statsfile = 'branchstats';
} else {
$statsfile = 'trunkstats';
}
if($version == 'branch') {
$statsfile = 'branchstats';
} else {
$statsfile = 'stats';
$statsfile = 'trunkstats';
}
if($i==1){
$pack = getdomain($pack);
@ -121,13 +118,14 @@ if($package=='alloff' || $package == 'allcore'){
}
}
}elseif($package=='allun'){
$packs = $existing_extra_packs;
$packs = ($version == 'trunk') ? $existing_extra_packs_t : $existing_extra_packs_b;
foreach($packs as $pack){
$pack = getdomain($pack);
if (!file_exists("stats/" . $pack . "/stats")) {
$statsfile = $version . 'stats';
if (!file_exists("stats/" . $pack . "/$statsfile")) {
continue;
}
$serialized = file_get_contents("stats/" . $pack . "/stats");
$serialized = file_get_contents("stats/" . $pack . "/$statsfile");
$tmpstats = array();
$tmpstats = unserialize($serialized);
foreach($tmpstats as $lang => $stat){
@ -147,11 +145,7 @@ if($package=='alloff' || $package == 'allcore'){
}
}else{
$package = $_GET['package'];
if(in_array($package,$existing_packs)){
$statsfile = $version . "stats";
} else {
$statsfile = "stats";
}
$statsfile = $version . "stats";
if (!file_exists("stats/" . $package . "/" . $statsfile)) {
$nostats=true;
}else{
@ -164,11 +158,7 @@ if(!$nostats){
//get total number of strings
$main_total=$stats["_pot"][1]+$stats["_pot"][2]+$stats["_pot"][3];
unset($stats["_pot"]);
if(in_array($firstpack,$existing_packs)){
$statsfile = $version . "stats";
} else {
$statsfile = "stats";
}
$statsfile = $version . "stats";
$filestat = stat("stats/" . $firstpack ."/" . $statsfile);
$date = $filestat[9];
@ -235,7 +225,6 @@ Version:
<? }else{ ?>
<strong>Development</strong> || <a href="?version=branch&amp;package=<?=$package?>"><?=$branch?></a>
<? } ?>
(only meaningful for official packs)
</td>
</tr>
<tr>
@ -273,7 +262,7 @@ echo "||";
$packs = $existing_packs;
echo "<br/>Official: ";
}else{
$packs = $existing_extra_packs;
$packs = ($version == 'trunk') ? $existing_extra_packs_t : $existing_extra_packs_b;
echo "<br/>Unofficial: ";
}
$first=true;