Skip to content

Commit

Permalink
added tsdiffmatrix.pl script
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dB authored and m0dB committed Jan 4, 2024
1 parent 0291eb2 commit 62437c2
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tools/tsdiffmatrix.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
sub help {
my $err = shift(@_);
if ($err) {
print "Error: $err\n\n";
}
print<<EOF;
Script to display a matrix with the amount of differences between translation files.
Usage:
Specify the list of .ts translation files to compare, e.g:
$ cd res/translations/
$ perl ../../tools/tsdiffmatrix.pl mixxx_es*.ts
$ for base in en es fr pt zh; do perl ../../tools/tsdiffmatrix.pl mixxx_\$base*.ts; done
EOF
exit(-1);
}

sub pad {
my $s = shift(@_);
return substr("$s ",0,5);
}

help() if $#ARGV == -1;
foreach $a (@ARGV) {
$a =~ m/mixxx.*_(\w+)\.ts/ || help("Unexpected argument $a");
}

print pad("");
foreach $a (@ARGV) {
if ($a =~ m/mixxx.*_(\w+)\.ts/) {
print pad($1);
}
}
print "\n";

foreach $b (@ARGV) {
$b =~ m/mixxx.*_(\w+)\./;
print pad($1);
foreach $a (@ARGV) {
$n = 0;
open(DIFFOUT,"diff $a $b |");
while (<DIFFOUT>) {
if (m/^(\d+),?(\d*)c(\d+),?(\d*)/) {
$na = $2 ? $2 - $1 : 1;
$nb = $4 ? $4 - $3 : 1;
$n += $na > $nb ? $na : $nb;
}
}
close(DIFFOUT);
print pad($a eq $b ? "" : $n);
}
print "\n";
}

print "--------------------------------------------------------------------\n";

0 comments on commit 62437c2

Please sign in to comment.