if line numbers does not match but translations are correct

This commit is contained in:
JohnnyRun
2015-03-15 12:07:01 +01:00
parent 1b70ea748b
commit 3be7fe3bf8

View File

@@ -20,31 +20,37 @@ open(masterfile, $masterfilename) || die("Could not open master file");
open(localefile, $localefilename) || die("Could not open locale file"); open(localefile, $localefilename) || die("Could not open locale file");
open(outfile, ">" . $outfilename) || die("Could not open output file"); open(outfile, ">" . $outfilename) || die("Could not open output file");
%master = {};
%locale = {};
while (<masterfile>) { while (<masterfile>) {
$masterline = $_; # master hash
($masterkey) = /([^ ]+)/; $line = $_;
($junk, $mastertext) = /([^ ]+)[ ]+([^\n]+)/; ($key) = /([^ ]+)/;
if ($last_was_ok) { ($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
$localeline = <localefile>; $master{$key} = $text;
chop $localeline; }
($localekey) = ($localeline =~ /([^ ]+)/,$localline);
($junk, $localetext) = ($localeline =~ /([^ ]+)[ ]+([^\n]+)/); while (<localefile>) {
}; # locale hash
if ($masterkey eq $localekey) { $line = $_;
print outfile $localeline, "\n"; ($key) = /([^ ]+)/;
$last_was_ok = 1; ($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
$locale{$key} = $text;
}
foreach $term (sort keys %master) {
if (exists $locale{$term}) {
print outfile $term, " ", $locale{$term}, "\n";
} else { } else {
$no_errors++; # not found
#print "|", $masterkey, "|", $mastertext, "|", $localekey, "|", $localetext, "|\n"; $no_errors++;
print outfile $masterkey, " TRANSLATE ", $mastertext, "\n"; print outfile $term, " TRANSLATE ", $master{$term}, "\n";
$last_was_ok = 0;
} }
} }
close(outfile); if ($no_errors == 0) {}
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
if ($no_errors == 0) {
unlink($outfilename); unlink($outfilename);
} else {
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
} }