[Pkg-shadow-devel] Re: About shadow translations...and Debian package development

Christian Perrier bubulle@kheops.frmug.org
Thu, 20 Jan 2005 07:10:04 +0100

Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by onera.onera.fr id j0K6s6cW023874

Quoting Tomasz K=C5=82oczko (kloczek@zie.pg.gda.pl):

> > So, I wonder how you proceed for getting these updates? Do these
> > people send it to you, or are you grabbing it from the Debian package=
> Yes. Sligtly bigger activity in this area have root in my broadcast-lik=
> email to Last-translators about try update this files :)

BTW, we have a nice script in Debian for this. It was originally aimed
at handling "debconf" translations (dunno how much you know about
details on Debian packaging=C2=A0: debconf is the interaction system with
the user when a package is installed. This is what produces these blue
screens asking questions....in the case of shadow these screens are
very important because some of them are used during the install of a
Debian system for prompting for the root password, new user to create
and so on).

Anyway, this script is attached to this mail. I guess you can use it
on your PO directory, provided you use the "--maintainer" and
"--podir" options.

> > I tested that with the French translation and merging the file from
> > the Debian package with the strings in 4.0.7 indeed gives 372t,34f

For French, we probably need to replace Vincent Renardias name. This
explains me why you still haven't a complete french translation.

I'll try to get you something complete by first merging the current
fr.po file we have in Debian with the current POT file (I think the
translations are better than original translations by Vincent) and
then complete the fuzzies.

> >=20
> > As I plan, in the future to resync both diverged versions, I really
> > need to understand how translations are handled currently for being
> > sure to be as efficient as possible.
> >=20
> > Something else=C2=A0:
> >=20
> > -do you have a mailing list for shadow development? I would certainly
> >  need to subscribe to it if it exists
> Yes. You can subscribe by send email to shadow-subscribe@pld.org.pl. It=
> also commit list (you can also subscribe by send email to=20
> shadow-commit-suscribe@pld.org.pl). Both list can be browsed by mailman=
> frontend on:

Will do.

> > -would you be OK for following the mailing list I have setup for the
> > Debian package development
> > (pkg-shadow-devel@lists.alioth.debian.org). The list will host
> > discussions in the package maintenance team (we currently are...two
> > people) and will also receive the bug reports from the Debian
> > BTS. Having you, as upstream maintainer, subscribed to it, could
> > certainly be an important help for us...and probably an interesting
> > input for you. Just let me know. No need indeed for following it
> > carefully (*that* will be my job)....
> OK. I'll subscribe to this list.
> BTW: I'm send emalls in last monday to Last-translators because in next=
> monday (24.01.2005) I plan release shadow 4.0.7 and still nothing was
> breaking this plans :)

Great. I think I'm still far from being able to resync the Debian
package. I first have to definitely take over the package (ie replace
the current maintainer) then build the team (I need more C-skilled
people) and then first built a package listing the team as maintainer,
but still based on 4.0.3.

This package will have all Debian specific patches isolated. I have
alredy noticed, when trying to apply them to 4.0.7, that several of
them have indeed been applied by you in upstream source.

So, the set of Debian specific patches for 4.0.7 will be quite
smaller....but there are still differences which we need to sort out
together. This is why I know I'll need you as well as other C-skilled
people in order to have people really understanding these patches and
decide whether they can be dropped, applied to upstream or kept as
specific Debian things.

Given that Debian sarge is still to be released and that I'm
personnally involved in lot of stuff in the project, further progress
will be slow. But, anyway, I'm very glad that the contact between
Debian shadow maintainers and shadow upstream is now working again
and, obviously, working well..:-)

Thanks for your responsiveness...

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=podebconf-report-po

#!/usr/bin/perl -w
# podebconf-report-po, Send outdated debconf po files to the last translator
# Copyright 2004 (C) Fabio Tranchitella <kobold@kobold.it>
#                    Denis Barbier <barbier@debian.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Library General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

## Release information
my $PROGRAM = "podebconf-report-po";
my $VERSION = "0.04";

## Loaded modules, require libmail-sendmail-perl
use strict;
eval q{use Mail::Sendmail;};
die "$PROGRAM: This program requires the libmail-sendmail-perl package.\n".
    "$PROGRAM: Aborting!\n" if $@;
use MIME::Base64;
use MIME::QuotedPrint;
use Getopt::Long;
use POSIX;

## Global variables
my $HELP_ARG = 0;
my $VERSION_ARG = 0;
my $VERBOSE_ARG = 0;
my $FORCE_ARG = 0;
my $SMTP_ARG = "";
my $TEMPLATE_ARG = "";
my $DEFAULT_ARG = 0;
my $PACKAGE_ARG = "";
my $FROM_ARG = "";
my $DEADLINE_ARG = "";
my $PODIR_ARG = "";

my $PODIR = '';
my @PODIRS = qw{../../debian/po ../debian/po debian/po};

my $CONTROL = '';
my @CONTROLS = qw{../../debian/control ../debian/control debian/control};

my $EDITOR = '/usr/bin/sensible-editor';
my $SMTP = '';

my $SUBJECT = "Please update debconf po translation for the package <package>";
my $BODY = "Hi,

you are noted as the last translator of the debconf translation for
<package>. The English template has been changed, and now a couple of
messages are marked \"fuzzy\" in your translation. I would be grateful
if you could take the time and update it. Please send the updated file
to me, or submit it as a wishlist bug against <package>.


## Handle options
 "help"            => \$HELP_ARG,
 "version"         => \$VERSION_ARG,
 "v|verbose"       => \$VERBOSE_ARG,
 "f|force"         => \$FORCE_ARG,
 "languageteam"    => \$LANGUAGETEAM_ARG,
 "smtp=s"          => \$SMTP_ARG,
 "template=s"      => \$TEMPLATE_ARG,
 "default"         => \$DEFAULT_ARG,
 "package=s"       => \$PACKAGE_ARG,
 "deadline=s"      => \$DEADLINE_ARG,
 "from=s"          => \$FROM_ARG,
 "podir=s"         => \$PODIR_ARG
 ) or &Help_InvalidOption;

&Help_PrintVersion if $VERSION_ARG;
&Help_PrintHelp if ($HELP_ARG);

## Try to find default editor
$EDITOR = $ENV{'EDITOR'} if exists($ENV{'EDITOR'});
$EDITOR = $ENV{'VISUAL'} if exists($ENV{'VISUAL'});

## Let's start to work ...
$SMTP = $SMTP_ARG if ($SMTP_ARG ne "");

my $i;

## Try to locate the po directory
if ($PODIR_ARG eq "") {
	foreach $i (@PODIRS) {
		$PODIR = $i if (-d $i);
} else {

## Try to find the maintainer e-mail address and the package name
if ($PACKAGE_ARG eq "" or $FROM_ARG eq "") {
	foreach $i (@CONTROLS) {
		$CONTROL = $i if (-f $i);

	if (-f $CONTROL) {
		##  Only read the first stanza
		local $/ = "\n\n";
		open (CNTRL, "< $CONTROL")
			or die "Unable to read $CONTROL: $!\n";
		my $text = <CNTRL>;
		close (CNTRL)
			or die "Unable to close $CONTROL: $!\n";
		if ($PACKAGE_ARG eq "" && $text =~ m/^Source: (.*)/mi) {
			$PACKAGE_ARG = $1;

		if ($FROM_ARG eq "" && $text =~ m/^Maintainer: (.*)/mi) {
			$FROM_ARG = $1;
Verbose("Package: $PACKAGE_ARG\nMaintainer: $FROM_ARG");

if ($DEADLINE_ARG ne "") {
  $DEADLINE_ARG = "\nThe deadline for receiving the updated translation is $DEADLINE_ARG.";

## Apply the values to the subject and to the body of the message
$SUBJECT =~ s/<package>/$PACKAGE_ARG/ig;
$BODY =~ s/<package>/$PACKAGE_ARG/ig;
$BODY =~ s/<from>/$FROM_ARG/ig;
$BODY =~ s/<deadline>\n/$DEADLINE_ARG/ig;

die "Directory po not found, exiting.\n" if $PODIR eq "";

## Analize every file with .po extension in $PODIR ...
Verbose("Checking for po files in $PODIR");
opendir(DIR, $PODIR);
my @files = ();
foreach my $file (grep(/\.po$/, readdir(DIR))) {
	local $/ = "\n\n";
	open (PO, "< $PODIR/$file")
		or die "Unable to read $PODIR/$file: $!\n";
	while (<PO>)
		#  Ignore header fields
		next if m/msgid ""\nmsgstr/s;
		#  Ignore outdated msgids
		next unless m/^msgid /m;
		if (m/^#, .*fuzzy/m) {
			push (@files, $file);
	close (PO)
		or die "Unable to close $PODIR/$file: $!\n";
if (@files) {
	print "Outdated files: ".join(' ', @files)."\n";
} else {
	print "No outdated files\n";

if ($TEMPLATE_ARG eq "") {
	$BODY = &OpenEditor($EDITOR) if not $DEFAULT_ARG;
} else {
	$BODY = &ReadFile($TEMPLATE_ARG);

$BODY = encode_qp($BODY);

my @mails = ();
foreach my $file (@files) {

	my $recipient = '';
	my $recipient_team = '';
	my $charset = '';
	local $/ = "\n\n";
	open (PO, "< $PODIR/$file")
		or die "Unable to read $PODIR/$file: $!\n";
	while (<PO>) {
		if (m/^msgid ""$/m) {
			if (m/^"Last-Translator: (.*?)(\\n)?"$/m) {
				$recipient = $1 if $1 ne 'FULL NAME <EMAIL@ADDRESS>';
			if ($LANGUAGETEAM_ARG && m/^"Language-Team: (.*?)(\\n)?"$/m) {
				$recipient_team = $1 if $1 ne 'LANGUAGE <LL@li.org>';
			if (m/^"Content-Type: .*; charset=(.*?)(\\n)?"$/m) {
				$charset = $1;

	close (PO)
		or die "Unable to close $PODIR/$file: $!\n";
	if ($recipient eq '') {
		warn "Warning: $file:  Unable to determine last translator.\n";
	print "  $file: $recipient";
	print ", $recipient_team" if $recipient_team ne "";
	print "\n";

	my $file_encoded = encode_base64(&ReadFile($PODIR . "/" . $file));
	my %mail = (
   			from => $FROM_ARG,
   			to => $recipient,
   			subject => $SUBJECT

	$mail{cc} = $recipient_team if $recipient_team ne "";

	$mail{smtp} = $SMTP if ($SMTP ne '');
	my $boundary = "=" . time() . "=";
	$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
	$mail{body} = <<_EOF_;
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Content-Type: text/x-gettext; name="$file"; charset="$charset"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$file"


	push(@mails, \%mail);

if (!$FORCE_ARG) {
	print "Ready to send the emails, are you sure? [y/N] ";
	my $line = <>;
	chop $line;
	exit(0) if ($line ne "Y" and $line ne "y");

#  Make Perl compiler quiet
print $Mail::Sendmail::error if 0;
foreach my $mail (@mails) {
	sendmail(%{$mail}) || print "Couldn't send the email: $Mail::Sendmail::error\n";


## Handle invalid arguments
sub OpenEditor
	my $editor = shift;

	my $body = "";
	my $opts = "";
	my $tmpnam = tmpnam();

	open (OUT, "> $tmpnam")
		or die ("Couldn't write $tmpnam: $!\nExiting!\n");
	print OUT $BODY;
		or die ("Couldn't close $tmpnam: $!\nExiting!\n");

	$opts = "-f" if ($editor eq "vim");
	system("$editor $opts $tmpnam");

	$body = &ReadFile($tmpnam) if (-f $tmpnam);

	return $body;

sub ReadFile
	my $file = shift;
	local $/ = undef;
	open(FILE, "< $file")
		or die ("Couldn't read $file: $!\nExiting!\n");
	my $body = <FILE>;
		or die ("Couldn't close $file: $!\nExiting!\n");
	return $body;

## Handle invalid arguments
sub Help_InvalidOption
	print STDERR "Try `${PROGRAM} --help' for more information.\n";
	exit 1;

## Print the usage message and exit
sub Help_PrintHelp
	print <<_EOF_;

Send outdated debconf po files to the last translators.

  --help                display this help and exit
  --version             display version information and exit
  -v, --verbose         display additional information
  -f, --force           send the email without confirmation
  --smtp=SERVER         specify SMTP server for mailing (default localhost)
  --template=TEMPLATE   specify file to use it as template for the emails
  --default             don't open the editor and use the template as is
  --package=PACKAGE     specify the name of the package
  --from=MAINTAINER     specify the name and the email address of the sender
  --deadline=DEADLINE   specify the deadline for receiving the updated
  --languageteam        send the email also to the Language Team as carbon copy
  --podir=PODIR         specify where are located the po files

	exit 0;

## Print the version text and exit
sub Help_PrintVersion
	print <<_EOF_;
Copyright (C) 2004 Fabio Tranchitella and Denis Barbier.
This is free software; see the source for copying conditions.  There is NO
	exit 0;

sub Verbose
	my $msg = shift;
	return unless $VERBOSE_ARG;
	$msg =~ s/^/**${PROGRAM}: /mg;
	print STDERR $msg."\n";