#!/usr/bin/perl use strict; my $use = <) { open(PO, $file); my $line; while($line = , $line =~ /^#/) { if ($line =~ m/^#\s*TWiki\s*translation\s*for\s*(.*)$/) { print $1, ":\n"; } if ($line =~ m/^#\s*(TWiki:Main\/\w*),/) { my $topic = $1; $topic =~ s#TWiki:#http://twiki.org/cgi-bin/view/#; print " $topic\n"; } } close(PO); } } my $raw = undef; my $upload = undef; if ($ARGV[0] eq '--help') { print $use; exit 0; } else { if ($ARGV[0] eq '--raw') { $raw = 1; } else { if ($ARGV[0] eq '--upload') { $upload = 1; } else { if ($ARGV[0] eq '--translators') { list_translators(); exit 0; } if ($ARGV[0]) { print $use; exit 1; } } } } my $text = ''; $text .= "| *Language* | *Translated* | *Fuzzy* | *Unstranslated* | *% translated* ||\n" unless $raw; for my $file () { print "I: Checking $file ...\n" unless $raw; my $output = `LANG=C msgfmt --statistics --output=/dev/null $file 2>&1`; if ($raw) { print "$file: $output"; next; } $file =~ s/locale\/([\w-]*).po/\1/; my ($translated, $fuzzy, $untranslated) = extract($output); my $total_translated = 100 * $translated / ($translated + $fuzzy + $untranslated); $text .= sprintf("| \%s | \%d | \%d | \%d | \%d%% |
 
 
|\n", $file, $translated, $fuzzy, $untranslated, $total_translated, $total_translated); } if ($upload) { use HTTP::Request::Common qw(POST); use LWP::UserAgent; use Date::Format; my $date = time2str('%d %b %Y', time); print 'WikiName: '; my $wikiname = ; print 'Password: '; system 'stty -echo'; my $password = ; system 'stty echo'; print "\n"; chomp($wikiname); chomp($password); $text = <new; $ua->agent("TWiki check_translations Script"); my $req = POST 'http://twiki.org/cgi-bin/save/Codev/TWikiTranslationStatus', [ text => $text ]; $req->authorization_basic($wikiname, $password); my $resp = $ua->request($req); if ($resp->is_redirect) { print "I: Translation status successfully uploaded to twiki.org!\n"; } else { print "E: Translation status not uploaded to twiki.org. Did you type your correct WikiName and password?\n"; print $resp->content; } } else { print $text; }