#!/usr/bin/perl -w # # rt_status.pl # # A script to summarize current status of the translation # efforts of the R-project # # Fernando Henrique Ferraz P Rosa # Created: 27/09/2005 # Last Update: 28/09/2005 # # use: # rt_status.pl langcode # # obs: edit $RSRCPATH to match the path to your R # sources # # $RSRCPATH = "/home/mentus/utils/R/development/espelho/r-devel"; $lang = $ARGV[0]; if (!(defined($lang))) { die("You must specify a language code\n"); } format STDOUT = @<<<< @<<<< @<<<< @<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $ppronto , $ptrans , $puntrans , $pfuzzy , $pnome . print "\tLanguage code : $lang\n\n"; print " % done T U F file name\n"; @lista = `find $RSRCPATH/ -name '*.pot'`; $sum_tot = 0; $sum_trans = 0; $sum_fuzzy = 0; $sum_untrans = 0; foreach $pot (@lista) { chomp($pot); $pot_trans = $pot; $pot_trans =~ s/R\.pot/$lang.po/; $pot_trans =~ s/RGui\.pot/RGui-$lang.po/; $pot_trans =~ s/\/R-.*\.pot/\/R-$lang.po/; $pot_trans =~ s/\/\w+\.pot/\/$lang.po/; $saida_t = `msgfmt --statistics $pot -o /dev/null 2> saida.tot`; open(PIPEG,"saida.tot"); $saida_t = ; if ($saida_t =~ m/, (\d+) untranslated/) { $n_total_pot = $1; } else { print "$saida_t\n"; die("Falha no arquivo $pot\n"); } close(PIPEG); if (!(-e $pot_trans)) { $n_trans_po = 0; } else { $saida = `msgfmt --statistics $pot_trans 2> saida.tmp`; open(PIPE,"saida.tmp"); $saida = ; chomp($saida); while ($saida !~ m/translated/) { $saida = ; chomp($saida); } close(PIPE); $match =0 ; if ($saida =~ m/(\d+) fuzzy translation/) { $n_fuzzy_po = $1; $match = 1; } else { $n_fuzzy_po = 0; } if ($saida =~ m/(\d+) translated message/) { $n_trans_po = $1; $match = 1; } else { $n_trans_po = 0; } if ($saida =~ m/(\d+) untranslated message/) { $n_untrans_po = $1; $match =1; } else { $n_untrans_po = 0; } if ($match == 0) { die("File $pot_trans contains no translated, no fuzzy and not even untranslated messages!\n"); } $n_total_po = $n_trans_po + $n_untrans_po; } $pnome = $pot_trans; $pnome =~ s/^$RSRCPATH\///g; if (-e $pot_trans) { $prop = 100*$n_trans_po/$n_total_po; $ppronto = $prop; $ptotal = $n_total_po; $pfuzzy = $n_fuzzy_po; $pnome = " $pnome"; $ptrans = $n_trans_po; $puntrans = $n_untrans_po; write; } else { $prop = 0; $n_fuzzy_po = 0; $n_trans_po = 0; $n_untrans_po = $n_total_pot; $ppronto = $prop; $pfuzzy = $n_fuzzy_po; $ptotal = $n_total_pot; $pnome = "*$pnome"; $ptrans = $n_trans_po; $puntrans = $n_untrans_po; write; } $sum_tot += $n_total_pot; $sum_trans += $n_trans_po; $sum_untrans += $n_untrans_po; $sum_fuzzy += $n_fuzzy_po; } if ($sum_tot == 0) { die("No messages found. Check your \$RSRCPATH.\n"); } $porc = 100*$sum_trans / $sum_tot; $ppronto = "-"; $ptrans = $sum_trans; $puntrans = $sum_untrans; $pfuzzy = $sum_fuzzy; $pnome = ""; write; print "\n\tDone "; printf ("%2.2f",$porc); print "% (T/(T+U))\n"; unlink("saida.tmp"); unlink("saida.tot"); unlink("messages.mo");