[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Improving translation workflow (was: multistrap: [INTL:pt] Repeated errors in PO submissions)



(skipping David's answer, wchi I mostly agree with. Thanks, David, for
taking care to de-escalate the issue with Neil, who is a longstanding
i18n-friendly person and who I don't like to see ranting because he's
also a friendly person in general..:-))

Quoting David Prévot (taffit@debian.org):

> That's a very good advice. Depending on the team, we often have a
> process that tries and guarantees the quality of the *content*
> translated, but we don't always check if the files work on the technical
> point of view. Please, don't hesitate to share your ideas to improve the
> technical part.


On my side, when I act as the barrier suggested by Neil (a kind of
"translation coordinator" between the maintainer and translators), I
use a few scriptsbefore committing files.

The main one is the one call "po_test" (attached along with
"check_var.pl"that it uses). I agree it should
be more widely exposed but it is in shorta quite crude hack and would
therefore need to be cleaned before being packaged.

Still, it may help those people in the i18n crowd who would like to
offer doing what David offers to do  with Neil : act as this "barrier"
between maintainers and translators. It would be interesting to have
this for internationalized Debian native packages (those packages
that, by definition, rely only on Debian for their localization). We
already have this for a few of these (dpkg, apt, aptitude, "Neilstrap"
packages...:-)).





#!/bin/sh
#
# Sync a PO file with a POT file
# test its charset
# check its validity
#
# Copyright © 2006-2008 Christian Perrier <bubulle@debian.org>
# Copyright © 2006 Denis Barbier <barbier@debian.org>

temp=`tempfile`
trap "rm -f $temp $temp.new" 1 2 3 15

clean_and_die() {
    rm -f $temp $temp.new
    if [ "$1" = "2" ] ; then
	echo Invalid encoding. Please check the file.
    fi
    exit $1
}


if [ -z $1 ]
then
  echo Usage $0 fichier
  clean_and_die 1
fi
if [ ! -f $1 ]
then
  echo $1 not found.
  clean_and_die 1
fi

if [ `ls -1 *\.pot 2>/dev/null | wc -l` != "1" ] ; then 
  echo No POT file \(or more than one\) in current directory
  clean_and_die 1
fi

potfile=`ls -1 *\.pot`
msgmerge -U --previous $1 $potfile
if msgcat $1 >$temp; then
	mv $temp $1
fi

enc=$(grep -E "^\"Content-Type" $1 | cut -f2 -d= | sed 's/\\n\"//g')

echo -n "Charset is $enc. Stats: "


if test -n "$enc" ; then
  iconv -f $enc -t UTF-8 $1 >$temp >/dev/null 2>&1 || clean_and_die 2
  if [ -x $HOME/bin/check_var.pl ] ; then
    $HOME/bin/check_var.pl $1 || clean_and_die 3
  else
    echo $HOME/bin/check_var.pl not found
    clean_and_die 1
  fi
  LC_ALL=C msgfmt -c -v -o /dev/null --statistics $1
  chmod 644 $1
fi


clean_and_die 0
#! /usr/bin/perl

sub getVars
{
        my $text = shift;
        my $var = '';
        while ($text =~ m/\G.*?(\$\{[^{}]+\})/g) {
                $var .= $1;
        }
        return $var;
}

$/ = "\n\n";
open (PO, "< $ARGV[0]") or die "Unable to open $ARGV[0]: $!\n";
while (<PO>)
{
        s/"\n"//g;
        (my $msgid) = m/^msgid "(.*)"$/m;
        (my $msgstr) = m/^msgstr "(.*)"$/m;
        next if $msgstr eq '' || m/^#, .*fuzzy/m;
        my $var1 = getVars($msgid);
        my $var2 = getVars($msgstr);
        print if $var1 ne $var2;
}
close (PO);

Attachment: signature.asc
Description: Digital signature


Reply to: