Commit c39cdce0 authored by Steve McIntyre's avatar Steve McIntyre

Fix up the special French translation check code in desc.wml

Re-write to use out generic VCS infrastructure like other scripst
Tweak the output to make more sense with salsa URLs
s/CVS/git/ in the descriptive text
parent 8abe1279
......@@ -30,27 +30,27 @@ dans le répertoire <tt>french/international/french/</tt> un
fichier <tt>translated_txt.db</tt>. Au moment d'une traduction, il faut
ajouter dans ce fichier une ligne au format suivant&nbsp;:
<kbd><var>répertoire</var>/<var>fichier</var>&nbsp;\
<var>version_cvs_du_fichier_original</var></kbd>, où la version
CVS du fichier original est précédée par une ou plusieurs espaces ou
<var>version_git_du_fichier_original</var></kbd>, où la version
git du fichier original est précédée par une ou plusieurs espaces ou
tabulations. Par exemple&nbsp;:</p>
<hr/>
<pre>
MailingLists/desc/user.heading 1.5
MailingLists/desc/bugs/debian-bugs-closed 1.4
MailingLists/desc/user.heading 905f7d54808257a5063248fd9fdcfb814a11e830
MailingLists/desc/bugs/debian-bugs-closed 1f33569863b60e57fd738363c6dfaaeaad024f83
devel/debian-jr/packaged/education/gcompris 1.2
devel/debian-jr/packaged/education/gcompris 45f176b9c63ef28a78c957a90126e4d712a7eb1b
devel/debian-jr/packaged-non-free/games-arcade/xmame 1.1
devel/debian-jr/packaged-non-free/games-arcade/xmame 98325575145d3c005dc3e47c5886fbb67b4f7dbd
</pre>
<hr/>
<p>
Si vous n'avez pas de droits en écriture dans le dépôt CVS, envoyez à la liste
Si vous n'avez pas de droits en écriture dans le dépôt git, envoyez à la liste
un diff. de ce fichier avec vos traductions.
</p>
<p>
Lorsque vous mettez à jour un fichier, il suffit de modifier en
conséquence la version du dépôt CVS dans le fichier <tt>translated_txt.db</tt>.
conséquence la version du dépôt git dans le fichier <tt>translated_txt.db</tt>.
Envoyez également un diff. de ce fichier si vous n'avez pas les droits.
</p>
......@@ -64,7 +64,8 @@ régulièrement sur cette page.
<h2>Statistiques de traduction des descriptions</h2>
<perl>
use lib "../../../Perl";
use Local::Cvsinfo;
use Local::VCS;
use Cwd 'cwd';
$wmlroot="../../..";
......@@ -88,7 +89,7 @@ my $file_title = "Fichier";
my $translated_title = "Traduction";
my $original_title = "Original";
my $comment_title = "Commentaire";
my $unifieddiff_title = "Diff. unifié";
my $unifieddiff_title = "Diff";
my $log_title = "Journal";
my $outdated_chapter = "Traductions dépassées";
my $untranslated_chapter = "Descriptions non traduites";
......@@ -96,7 +97,15 @@ my $translated_chapter = "Traductions à jour";
# There should be no need to change anything below.
my $cvs = Local::Cvsinfo->new();
my $VCS = Local::VCS->new();
# Cache the repo state - we're going to be looking for commit details
# on lots of files below
my $current = cwd;
chdir($wmlroot) or die "Can't chdir to $wmlroot: $!\n";
$VCS->cache_repo();
chdir($current);
my $untranslated=0;
my $uptodate=0;
my $outdated=0;
......@@ -106,10 +115,12 @@ my $uptodate_string="";
my $untranslated_string="";
my %translated_files;
my $VCSBASE = "https://salsa.debian.org/webmaster-team/webwml";
open CHECK, "translated_txt.db" or die "You have to create a translated_txt.db in this directory";
while (my $line = <CHECK>)
{
if (($line =~ m%^([A-Za-z0-9\/\.\-\_]*)[\ \t]*([0-9]+\.[0-9]+)$%)
if (($line =~ m%^([A-Za-z0-9\/\.\-\_]*)[\ \t]*(\S++)$%)
and (-e "$wmlroot/$language/$1"))
{
$translated_files{$1} = $2;
......@@ -171,15 +182,22 @@ sub process
my $dir = $file;
$dir =~ s{/+[^/]+$}{};
my $version = get_version($dir, $file);
if ($version eq $translated_files{$global_file})
my $version_diff = $VCS->count_changes($file, $translated_files{$global_file}, $version);
# print STDERR "$global_file: trans version $translated_files{$global_file}, orig version $version, diff $version_diff \n";
if ($version_diff == 0)
{
$uptodate_string .= "$global_file<br />\n";
$uptodate++;
} else {
$outdated_string .= "<tr><td>$global_file</td><td>$translated_files{$global_file}</td>";
$outdated_string .= "<td>$version</td><td>$outofdate_message</td>";
$outdated_string .= sprintf "<td>&nbsp;&nbsp;<a href=\"https://anonscm.debian.org/viewvc/webwml/webwml/english/%s\?r1=%s\&amp;r2=%s\&amp;diff_format=%s\">%s → %s</a></td>", $global_file, $translated_files{$global_file}, $version, "u", $translated_files{$global_file}, $version;
$outdated_string .= sprintf "<td><a href=\"https://anonscm.debian.org/viewvc/webwml/webwml/english/%s#rev%s\">[L]</a></td>", $global_file, $version;
$outdated_string .= "<tr>";
$outdated_string .= "<td>$global_file</td>";
$outdated_string .= sprintf "<td>%s</td>", short($translated_files{$global_file});
$outdated_string .= sprintf "<td>%s</td><td>$outofdate_message</td>", short($version);
$outdated_string .= sprintf "<td>&nbsp;&nbsp;<a href=\"%s\">", vcs_diff_url("english/$global_file", $translated_files{$global_file}, $version, "u");
$outdated_string .= sprintf "%s → %s</a></td>", short($translated_files{$global_file}), short($version);
$outdated_string .= sprintf "<td><a href=\"%s\">", vcs_log_url("english/$global_file", $version);
$outdated_string .= "[L]</a></td>";
$outdated_string .= "</tr>\n";
$outdated++;
}
......@@ -192,9 +210,24 @@ sub process
sub get_version
{
my ($dir, $file) = @_;
$cvs->reset();
$cvs->readinfo($dir, matchfile => [$file]);
return $cvs->revision($file);
my %info = $VCS->file_info("$file");
return $info{'cmt_rev'};
}
sub vcs_diff_url {
my ( $path, $r1, $r2, $diff_format ) = @_;
return "$VCSBASE/compare?from=$r1&to=$r2";
}
sub vcs_log_url {
my ($path, $rev) = @_;
return "$VCSBASE/commits/$rev/$path";
}
# Return a shortened version string to make things less unwieldy
sub short {
my $in = shift;
return substr $in, 0, 12; # 12 is a common length people use for git
}
<perl:print>$uptodate $uptodate_summary, $outdated $outofdate_summary, $untranslated $untranslated_summary\n</perl:print>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment