Hello, here is a little patch to the script check_trans.pl.
What it does: - if '-m' is given, mails the maintainers of translations which are outdated, sending the diff between the translated version and the current one. - accept a default recipient as option to the -m arg - if -g (debuG) is given, all mails are send to the default recipient - if exists, reads the database (for example, french/international/french/curent_status.pl) to get the good translator. if not exists or the entrie not found in DB, parse the file to find a line 'translate by' in the source file - more verbose outputs : o added the revision for 'Missing file' o added the old revision and the maintainer for 'NeedToUpdate' - cosmetic change: all regexp are changed from s#blah#bla# to s,blah,bla, because emacs thinks they are comments if not. How it was tested: - only dry runs, (with -g) in french subdir. I wait for an ACK of the others french translator before to spam them. I am not developer, so if someone could review and commit this patch, I would proud to help Debian. Bye, Mt.
--- check_trans.pl Wed Nov 29 11:55:07 2000 +++ check_trans.pl.new Wed Nov 29 11:54:54 2000 @@ -14,6 +14,10 @@ # -d output diff # -l output log messages # -q don't whine about missing files +# -g debuG +# -m makes mails to translation maintainers +# (if -m is given, it must be followed by the default recipient) +# (I sent it to [email protected]) # If you do not specify a language on the command line, it will try to load # one from a file called language.conf, if such a file exists. That file @@ -37,7 +41,10 @@ $opt_s = ''; $opt_p = undef; $opt_l = 0; -getopts('vdqs:p:l'); +$opt_g = 0; +$opt_m = ''; +getopts('vgdqm:s:p:l'); +$maintainer = "[EMAIL PROTECTED]"; #adress of maintainer of this script warn "Checking subtree $opt_s only\n" if $opt_v; @@ -62,37 +69,97 @@ # Remove slash from end $to =~ s%/$%%; +if (-e "./$to/international/$to/current_status.pl") { + print "READ DB\n"; + push(@INC,"./$to/international/$to"); + require 'current_status.pl'; +} +$langto=$to; $from = "$from/$opt_s"; $to = "$to/$opt_s"; +my %tomail; # mails to send + @en= split(/\n/, `find $from -name Entries -print`); $showlog = $opt_l; + foreach (@en) { next if $_ =~ "template/debian"; my ($path, $tpath, $d); $path = $_; - $path =~ s#CVS/Entries$##; + $path =~ s,CVS/Entries$,,; $tpath = $path; $tpath =~ s/^$from/$to/o; - $d = load_entries($_); + %d = %{load_entries($_)}; $ignore = load_ignorelist($tpath); - foreach $f (keys %$d) { - check_file("${tpath}$f", $d->{$f}) unless $$ignore{"${tpath}$f"}; + foreach $f (keys %{$d{"rev"}}) { + check_file("${tpath}$f", + $d{"rev"}->{$f}, + get_translators_from_db("$tpath$f")) + unless $$ignore{"${tpath}$f"}; } } +#Makes the mails +if ($opt_m) { + foreach $name (sort keys %tomail) { + $adr = ($opt_g ? $opt_m : $name); + open MAIL,"|/usr/sbin/sendmail -t " || die "can't pipe to sendmail"; + print MAIL "From: $maintainer\n"; + print MAIL "To: $adr\n"; + print MAIL "Subject: Status of your translations for the debian web site\n"; + print MAIL "Reply-to: $opt_m\n\n"; + print MAIL <<EOM; +Hello, +This is a automatically generated mail sent to you +because you are the official translator of some pages +in $langto of the Debian web site. + +I send you the diff between the version you translated and +the current version to allow you to update your work. + +For more informations, contact your team coordinator, or +the Debian web-masters ($maintainer). + +Thanks, and sorry for the annoyance. +EOM + print MAIL "------------ MAIL TO $name\n" if $opt_g; + foreach $n (@{$tomail{$name}}) { + print MAIL "$n\n\n"; + } + close MAIL || die "Can't send mail"; + } +} + +sub get_translators_from_db { + my $id=shift; + my $res=''; + + $id=~ s,^$langto/,,; + $id=~ s/\.wml$//; + if (defined(%{$$translations_status{$id}}) + && defined ($$translations_status{$id}{'translation_maintainer'})) { + foreach $n (sort @{$$translations_status{$id}{'translation_maintainer'}}) { + $res .= " $n"; + } + } else { + $res = ""; + } + return $res; +} + sub load_entries { my ($name) = shift; my (%data); warn "Loading $name\n" if ($opt_v && !$opt_q); open(F, $name) || die $!; while(<F>) { - next unless m#^/#; - if ( m#^/([^/]+)/([^/]+)/# ) { + next unless m,^/,; + if ( m,^/([^/]+)/([^/]+)/, ) { my($name, $rev) =($1, $2); - $data{$name} = $rev if $name =~ /$filename/o; + $data{"rev"}->{$name} = $rev if $name =~ /$filename/o; } } close (F); @@ -113,11 +180,11 @@ } sub check_file { - my ($name, $revision) = @_; + my ($name, $revision, $translator) = @_; my ($oldr, $oldname); - warn "Checking $name\n" if $opt_v; + warn "Checking $name english revision $revision\n" if $opt_v; unless (-r $name) { - print "Missing $name\n" unless $opt_q; + print "Missing $name version $revision\n" unless $opt_q; return; } open(F, $name) || die $!; @@ -125,25 +192,37 @@ if (/translation(\s+|=")([.0-9]*)("|\s*-->)/oi) { warn "Found revision $2\n" if $opt_v; $oldr = $2; - if ($oldr eq $revision) { - close(F); - return; - } - last; + } + if (/Translat(.*?): (.*)$/i) { + warn "Translated by $2\n" if $opt_v; + $translator=$2 if ($translator eq ""); } } close(F); + return if ($oldr eq $revision); + + $oldr ||= '1.1'; + print "NeedToUpdate $name from version $oldr to version $revision"; + print " (maintainer: $translator)" if $translator; + print "\n"; + $oldname = $name; + $oldname =~ s/^$to/$from/; + if ($opt_m) { + $translator = $opt_m if ($translator eq ""); +# $tmp="+++++++++++++++++++++++++++++ LOG OF $oldname\n"; +# $tmp.=`cvs -z3 log -r'$oldr:$revision' '$oldname'`; +# $tomail{$translator}[scalar @{$tomail{$translator}}]=$tmp; + $tmp="+++++++++++++++++++++++++++++ CHANGES IN $oldname\n"; + $tmp.=`cvs -z3 diff -u -r'$oldr' -r '$revision' '$oldname'`; + $tmp.="+++++++++++++++++++++++++++++ END OF $oldname\n"; + $tomail{$translator}[scalar @{$tomail{$translator}}].="\n".$tmp; + } + if ($opt_d) { - $oldr ||= '1.1'; - $oldname = $name; - $oldname =~ s/^$to/$from/; STDOUT->flush; system("cvs -z3 log -r'$oldr:$revision' '$oldname'") if $showlog; STDOUT->flush if $showlog; system("cvs -z3 diff -u -r '$oldr' -r '$revision' '$oldname'"); STDOUT->flush; - } else { - print "NeedToUpdate $name to version $revision\n"; - } + } } -

