tags 380342 patch
thanks

Hello,

On Sat, Jul 29, 2006 at 01:50:32PM +0200, Luk Claes wrote:
> 
> Can you please add an option to only send for specific file(s)? It would
> be very usefull when you see that some mails get bounced that you could
> be able to use the tool for some file(s) only. This could be used for
> adding the languageteam option for these that failed or when you fixed a
> spelling error in the email addresses for instance.

Here is a proposal for implementing this feature.

The patch adds a --langs=LANGUAGES option.

specifying --langs fr,de will restrict sending emails only to the French
or German translator (only if the PO is not up-to-date).

It also add some brackets in the header of the template. Here is an
extract, with podebconf-report-po started with the
"--languageteam --langs fr,de" options

# This mail will be sent to the following people:
# (you can update email addresses, remove a line or add/remove the cross
# between the brackets)
### [*] de.po: Nicolas Fran?ois de <[EMAIL PROTECTED]>, French lang_de <[EMAIL 
PROTECTED]>
### [ ] he.po: Nicolas Fran?ois he <[EMAIL PROTECTED]>, French lang_he <[EMAIL 
PROTECTED]>

This allow maintainers changing the emails / list of notified translators.

Kind Regards,
-- 
Nekral
Index: podebconf-report-po
===================================================================
RCS file: /cvsroot/po4a/po-debconf/podebconf-report-po,v
retrieving revision 1.16
diff -u -r1.16 podebconf-report-po
--- podebconf-report-po 25 Jun 2006 20:42:26 -0000      1.16
+++ podebconf-report-po 30 Sep 2006 13:32:07 -0000
@@ -45,6 +45,7 @@
 my $VERBOSE_ARG = 0;
 my $SUBMIT_ARG = 0;
 my $FORCE_ARG = 0;
+my $LANGS = "";
 my $LANGUAGETEAM_ARG = 0;
 my $SMTP_ARG = "";
 my $TEMPLATE_ARG = "";
@@ -77,6 +78,8 @@
 # Reply-To: <reply-to>
 #
 # This mail will be sent to the following people:
+# (you can update email addresses, remove a line or add/remove the cross
+# between the brackets)
 <filelist>
 
 Hi,
@@ -129,6 +132,7 @@
  "template=s"      => \$TEMPLATE_ARG,
  "default"         => \$DEFAULT_ARG,
  "gzip"            => \$GZIP_ARG,
+ "langs=s"         => \$LANGS,
  "languageteam"    => \$LANGUAGETEAM_ARG,
  "package=s"       => \$PACKAGE_ARG,
  "deadline=s"      => \$DEADLINE_ARG,
@@ -317,12 +321,19 @@
        exit(0);
 }
 
+my %langs=();
+foreach (split(",", $LANGS)) {
+       $langs{$_.".po"} = 1;
+}
+
 my $filelist = '';
 if ($SUBMIT_ARG) {
        $filelist = join(' ', sort keys %$poFiles)."\n";
 } else {
        foreach my $poFile (sort keys %$poFiles) {
-               $filelist .= '### ' . $poFile . ': ' . 
$poFiles->{$poFile}->{translator};
+               $filelist .= '### ';
+               $filelist .= '[' .((!%langs or $langs{$poFile})?'*':' '). '] ';
+               $filelist .= $poFile . ': ' . $poFiles->{$poFile}->{translator};
                $filelist .= ', ' . $poFiles->{$poFile}->{team} if 
defined($poFiles->{$poFile}->{team});
                $filelist .= "\n";
        }
@@ -338,6 +349,7 @@
        $BODY = &ReadFile($TEMPLATE_ARG);
 }
 %headers = &ParseHeaders($BODY);
+my %To = &ParseTo($BODY);
 $BODY = &RemoveHeaders($BODY);
 
 print STDERR $warn if $warn ne '';
@@ -357,18 +369,17 @@
        $BODY = encode_qp($BODY);
        my $ext = ($GZIP_ARG ? '.gz' : '');
        foreach my $file (keys %$poFiles) {
+           if (defined $To{$file}) {
                my $content = &ReadFile($PODIR . "/" . $file);
                $content = Compress::Zlib::memGzip($content) if $GZIP_ARG;
                my $file_encoded = encode_base64($content);
                my $contentType = ($GZIP_ARG ? "application/octet-stream" : 
"text/x-gettext; name=\"$file\"; charset=\"$poFiles->{$file}->{charset}\"");
                my %mail = (
                        From => $FROM_ARG,
-                       To => $poFiles->{$file}->{translator},
+                       To => $To{$file},
                        Subject => $SUBJECT,
                        'X-Mail-Originator' => "$PROGRAM $VERSION"
                );
-               $mail{To} .= ", ". $poFiles->{$file}->{team}
-                       if defined $poFiles->{$file}->{team};
 
                my $boundary = "=" . time() . "=";
                $mail{'content-type'} = "multipart/mixed; 
boundary=\"$boundary\"";
@@ -389,6 +400,7 @@
 _EOF_
 
                push(@mails, \%mail);
+           }
        }
 }
 
@@ -476,6 +488,20 @@
        return %headers;
 }
 
+sub ParseTo
+{
+       my $body = shift;
+       my %To = ();
+
+       while ($body =~ s/#[ \t]*([^\n]*)\n//s) {
+               my $comment = $1;
+               if ($comment =~ s/^##[ \t]*\[(?:\*|x)\][ \t]*([^:]*):[ 
\t]*([^\n]*)$//s) {
+                       $To{$1} = $2;
+               }
+       }
+       return %To;
+}
+
 sub RemoveHeaders
 {
        my $body = shift;
@@ -533,6 +559,7 @@
   --from=MAINTAINER     specify the name and the email address of the sender
   --deadline=DEADLINE   specify the deadline for receiving the updated
                         translations
+  --langs=LANGUAGES     restrict sending emails only to these languages
   --languageteam        send the email also to the Language Team
   --summary             send a status report to the maintainer with the list
                         of emails sent to translators
Index: doc/en/podebconf-report-po.1.pod
===================================================================
RCS file: /cvsroot/po4a/po-debconf/doc/en/podebconf-report-po.1.pod,v
retrieving revision 1.3
diff -u -r1.3 podebconf-report-po.1.pod
--- doc/en/podebconf-report-po.1.pod    25 Jun 2006 21:02:02 -0000      1.3
+++ doc/en/podebconf-report-po.1.pod    30 Sep 2006 13:32:07 -0000
@@ -71,6 +71,13 @@
 Specify the deadline for receiving the updated translations (default is
 no deadline).
 
+=item B<--langs=I<LANGUAGES>>
+
+Specify a list of languages to restrict ending the notification only for
+these languages.
+The list on languages is comma separated. The PO files must be named
+according to these languages, with the .po extension.
+
 =item B<--languageteam>
 
 Send the email also to the Language Team as carbon copy.

Reply via email to