| 20 |
# - compare both major and minor revision number |
# - compare both major and minor revision number |
| 21 |
# - think of a better way to check when the file has been rebuilt last |
# - think of a better way to check when the file has been rebuilt last |
| 22 |
|
|
| 23 |
|
# These modules reside under webwml/Perl |
| 24 |
# This should contain all languages |
use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl"; |
| 25 |
@langs = ("arabic", "chinese", "croatian", "danish", "dutch", "english", |
use Local::Cvsinfo; |
| 26 |
"esperanto", "finnish", "french", "german", "hungarian", |
use Webwml::Langs; |
| 27 |
"italian", "japanese", "korean", "norwegian", "polish", |
use Webwml::TransCheck; |
|
"portuguese", "romanian", "russian", "spanish", "swedish", |
|
|
"turkish"); |
|
| 28 |
|
|
| 29 |
# Set this to 1 for debugging |
# Set this to 1 for debugging |
| 30 |
$debug = 1; |
$debug = 0; |
| 31 |
|
|
| 32 |
sub rebuild { |
sub rebuild { |
| 33 |
my $file = shift; |
my $file = shift; |
| 34 |
$now = time; |
$now = time; |
| 35 |
print "touching $file\n"; |
print "touching $file\n" if $debug; |
| 36 |
utime $now, $now, $file or die "$file: $!"; |
utime $now, $now, $file or die "$file: $!"; |
| 37 |
} |
} |
| 38 |
|
|
| 72 |
} |
} |
| 73 |
} |
} |
| 74 |
|
|
| 75 |
|
# We call constructor without argument. It means there must be a |
| 76 |
|
# CVS/Repository file or program will abort. |
| 77 |
|
my $l = Webwml::Langs->new(); |
| 78 |
|
my %langs = $l->iso_name(); |
| 79 |
|
my @langs = $l->names(); |
| 80 |
|
|
| 81 |
$argfile = $ARGV[0] or die "Invalid number of arguments"; |
$argfile = $ARGV[0] or die "Invalid number of arguments"; |
| 82 |
$arglang = $ARGV[1] or die "Invalid number of arguments"; |
die "Invalid number of arguments" unless $ARGV[1]; |
| 83 |
$argfile =~ m+(.*)/(.*)\.wml+ or die "pattern does not match"; |
$arglang = $langs{$ARGV[1]} or die "Invalid lang argument: $ARGV[1]"; |
| 84 |
|
$argfile =~ m+(.*)/(.*\.wml)+ or die "pattern does not match"; |
| 85 |
my ($path, $file) = ($1, $2); |
my ($path, $file) = ($1, $2); |
| 86 |
|
|
| 87 |
# Get the revision of the original file |
my $cvs = Local::Cvsinfo->new(); |
| 88 |
my $origrev; |
$cvs->options(matchfile => [ $file ]); |
| 89 |
open FILE, "${path}/CVS/Entries" or die "${path}/CVS/Entries: $!"; |
$cvs->readinfo($path); |
| 90 |
while (<FILE>) { |
my $origrev = $cvs->revision($argfile) || "1.0"; |
|
if (m,^/$file.wml/([^/]+)/,) { |
|
|
$origrev = $1; |
|
|
last; |
|
|
} |
|
|
} |
|
| 91 |
|
|
| 92 |
foreach $lang (@langs) { |
foreach $lang (@langs) { |
| 93 |
next if ($lang eq $arglang); |
next if ($lang eq $arglang); |
| 94 |
my $transfile = $argfile; |
my $transfile = $argfile; |
| 95 |
my ($maxdelta, $mindelta) = (5, 2); |
my ($maxdelta, $mindelta) = (5, 2); |
| 96 |
my ($original, $langrev); |
my ($original, $langrev); |
| 97 |
print "Now checking $lang\n"; |
print "Now checking $lang\n" if $debug; |
| 98 |
$transfile =~ s+$arglang+$lang+ or die "wrong argument: pattern does not match file: $transfile"; |
$transfile =~ s+$arglang+$lang+ or die "wrong argument: pattern does not match file: $transfile"; |
| 99 |
|
|
| 100 |
# Parse the translated file |
# Parse the translated file |
| 101 |
open FILE, "$transfile" or next; |
my $transcheck = Webwml::TransCheck->new($transfile); |
| 102 |
while (<FILE>) { |
next unless $transcheck->revision(); |
| 103 |
if (/translation-check translation="([.0-9]*)"\s*(.*)/oi) { |
$langrev = $transcheck->revision(); |
| 104 |
$langrev = $1; |
$original = $transcheck->original(); |
| 105 |
my $stuff = $2; |
$maxdelta = $transcheck->maxdelta() if $transcheck->maxdelta(); |
| 106 |
if ($stuff =~ /original="([^"]+)"/) { |
$mindelta = $transcheck->mindelta() if $transcheck->mindelta(); |
|
$original = $1; |
|
|
} |
|
|
if ($stuff =~ /maxdelta="([^"]+)"/) { |
|
|
$maxdelta = $1; |
|
|
} |
|
|
if ($stuff =~ /mindelta="([^"]+)"/) { |
|
|
$mindelta = $1; |
|
|
} |
|
|
last; |
|
|
} |
|
|
} |
|
|
close FILE; |
|
|
next if not defined $langrev; |
|
| 107 |
# TODO - would cause unspecified results if 1. changed to 2. |
# TODO - would cause unspecified results if 1. changed to 2. |
| 108 |
$origrev =~ s/1\.//; |
$origrev =~ s/1\.//; |
| 109 |
$langrev =~ s/1\.//; |
$langrev =~ s/1\.//; |