mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Added handling for git revisions
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39232 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d958d89b35
commit
e53a3a089c
169
po/diff_po.pl
169
po/diff_po.pl
@ -34,77 +34,116 @@ my %Fuzzy = (); # inside new po-file
|
||||
my $result = 0; # exit value
|
||||
my $printlines = 0;
|
||||
my @names = ();
|
||||
my $tmpfile = "/tmp/blax";
|
||||
|
||||
#
|
||||
while(defined($ARGV[0])) {
|
||||
last if ($ARGV[0] !~ /^\-/);
|
||||
my $param = shift(@ARGV);
|
||||
if ($param eq "-L") {
|
||||
my $name = shift(@ARGV);
|
||||
push(@names, $name);
|
||||
# Check first, if called as standalone program for git
|
||||
if ($ARGV[0] =~ /^-r(.*)/) {
|
||||
my $rev = $1;
|
||||
shift(@ARGV);
|
||||
if ($rev eq "") {
|
||||
$rev = shift(@ARGV);
|
||||
}
|
||||
for my $argf (@ARGV) {
|
||||
my $baseargf;
|
||||
($baseargf = $argf) =~ s/^.*\///;
|
||||
my @args = ();
|
||||
push(@args, "-L", $argf . " (" . $rev . ")");
|
||||
push(@args, "-L", $argf . " (local copy)");
|
||||
open(FI, "git show $rev:po/$baseargf|");
|
||||
open(FO, '>', $tmpfile);
|
||||
while(my $l = <FI>) {
|
||||
print FO $l;
|
||||
}
|
||||
close(FI);
|
||||
close(FO);
|
||||
push(@args, $tmpfile, $argf);
|
||||
&diff_po(@args);
|
||||
}
|
||||
}
|
||||
if (! defined($names[0])) {
|
||||
push(@names, "original");
|
||||
else {
|
||||
&diff_po(@ARGV);
|
||||
}
|
||||
if (! defined($names[1])) {
|
||||
push(@names, "new");
|
||||
}
|
||||
|
||||
if (@ARGV != 2) {
|
||||
die('"', join('" "', @names, @ARGV) . "\" Expected exactly 2 parameters");
|
||||
}
|
||||
|
||||
&check($names[0], $ARGV[0]);
|
||||
&check($names[1], $ARGV[1]);
|
||||
|
||||
&parse_po_file($ARGV[0], \%Messages);
|
||||
&parse_po_file($ARGV[1], \%newMessages);
|
||||
|
||||
my @MsgKeys = &getLineSortedKeys(\%newMessages);
|
||||
|
||||
print RED "<<< \"$names[0]\"\n", RESET;
|
||||
print GREEN ">>> \"$names[1]\"\n", RESET;
|
||||
for my $k (@MsgKeys) {
|
||||
if ($newMessages{$k}->{msgstr} eq "") {
|
||||
# this is still untranslated string
|
||||
$Untranslated{$newMessages{$k}->{line}} = $k;
|
||||
}
|
||||
elsif ($newMessages{$k}->{fuzzy}) {
|
||||
#fuzzy string
|
||||
$Fuzzy{$newMessages{$k}->{line}} = $k;
|
||||
}
|
||||
if (exists($Messages{$k})) {
|
||||
&printIfDiff($k, $Messages{$k}, $newMessages{$k});
|
||||
delete($Messages{$k});
|
||||
delete($newMessages{$k});
|
||||
}
|
||||
}
|
||||
|
||||
@MsgKeys = &getLineSortedKeys(\%Messages);
|
||||
for my $k (@MsgKeys) {
|
||||
$result |= 8;
|
||||
print "deleted message\n";
|
||||
print "< line = " . $Messages{$k}->{line} . "\n" if ($printlines);
|
||||
print RED "< fuzzy = " . $Messages{$k}->{fuzzy} . "\n", RESET;
|
||||
print RED "< msgid = \"$k\"\n", RESET;
|
||||
print RED "< msgstr = \"" . $Messages{$k}->{msgstr} . "\"\n", RESET;
|
||||
}
|
||||
|
||||
@MsgKeys = &getLineSortedKeys(\%newMessages);
|
||||
for my $k (@MsgKeys) {
|
||||
$result |= 16;
|
||||
print "new message\n";
|
||||
print "> line = " . $newMessages{$k}->{line} . "\n" if ($printlines);
|
||||
print GREEN "> fuzzy = " . $newMessages{$k}->{fuzzy} . "\n", RESET;
|
||||
print GREEN "> msgid = \"$k\"\n", RESET;
|
||||
print GREEN "> msgstr = \"" . $newMessages{$k}->{msgstr} . "\"\n", RESET;
|
||||
}
|
||||
|
||||
&printExtraMessages("fuzzy", \%Fuzzy);
|
||||
&printExtraMessages("untranslated", \%Untranslated);
|
||||
|
||||
exit($result);
|
||||
#########################################################
|
||||
|
||||
sub diff_po($$)
|
||||
{
|
||||
my @args = @_;
|
||||
%Messages = ();
|
||||
%newMessages = ();
|
||||
%Untranslated = ();
|
||||
%Fuzzy = ();
|
||||
@names = ();
|
||||
print "========================================================\n";
|
||||
while(defined($args[0])) {
|
||||
last if ($args[0] !~ /^\-/);
|
||||
my $param = shift(@args);
|
||||
if ($param eq "-L") {
|
||||
my $name = shift(@args);
|
||||
push(@names, $name);
|
||||
}
|
||||
}
|
||||
if (! defined($names[0])) {
|
||||
push(@names, "original");
|
||||
}
|
||||
if (! defined($names[1])) {
|
||||
push(@names, "new");
|
||||
}
|
||||
|
||||
if (@args != 2) {
|
||||
die("names = \"", join('" "', @names) . "\"... args = \"" . join('" "', @args) . "\" Expected exactly 2 parameters");
|
||||
}
|
||||
|
||||
&check($names[0], $args[0]);
|
||||
&check($names[1], $args[1]);
|
||||
|
||||
&parse_po_file($args[0], \%Messages);
|
||||
&parse_po_file($args[1], \%newMessages);
|
||||
|
||||
my @MsgKeys = &getLineSortedKeys(\%newMessages);
|
||||
|
||||
print RED "<<< \"$names[0]\"\n", RESET;
|
||||
print GREEN ">>> \"$names[1]\"\n", RESET;
|
||||
for my $k (@MsgKeys) {
|
||||
if ($newMessages{$k}->{msgstr} eq "") {
|
||||
# this is still untranslated string
|
||||
$Untranslated{$newMessages{$k}->{line}} = $k;
|
||||
}
|
||||
elsif ($newMessages{$k}->{fuzzy}) {
|
||||
#fuzzy string
|
||||
$Fuzzy{$newMessages{$k}->{line}} = $k;
|
||||
}
|
||||
if (exists($Messages{$k})) {
|
||||
&printIfDiff($k, $Messages{$k}, $newMessages{$k});
|
||||
delete($Messages{$k});
|
||||
delete($newMessages{$k});
|
||||
}
|
||||
}
|
||||
|
||||
@MsgKeys = &getLineSortedKeys(\%Messages);
|
||||
for my $k (@MsgKeys) {
|
||||
$result |= 8;
|
||||
print "deleted message\n";
|
||||
print "< line = " . $Messages{$k}->{line} . "\n" if ($printlines);
|
||||
print RED "< fuzzy = " . $Messages{$k}->{fuzzy} . "\n", RESET;
|
||||
print RED "< msgid = \"$k\"\n", RESET;
|
||||
print RED "< msgstr = \"" . $Messages{$k}->{msgstr} . "\"\n", RESET;
|
||||
}
|
||||
|
||||
@MsgKeys = &getLineSortedKeys(\%newMessages);
|
||||
for my $k (@MsgKeys) {
|
||||
$result |= 16;
|
||||
print "new message\n";
|
||||
print "> line = " . $newMessages{$k}->{line} . "\n" if ($printlines);
|
||||
print GREEN "> fuzzy = " . $newMessages{$k}->{fuzzy} . "\n", RESET;
|
||||
print GREEN "> msgid = \"$k\"\n", RESET;
|
||||
print GREEN "> msgstr = \"" . $newMessages{$k}->{msgstr} . "\"\n", RESET;
|
||||
}
|
||||
|
||||
&printExtraMessages("fuzzy", \%Fuzzy);
|
||||
&printExtraMessages("untranslated", \%Untranslated);
|
||||
}
|
||||
|
||||
sub check($$)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user