Files
recycled-ni-neutrino/data/locale/helpers/create-locals-work
JohnnyRun 6b29897ddf if line numbers does not match but translations are correct
Origin commit data
------------------
Branch: ni/coolstream
Commit: 2a0c4347ad
Author: JohnnyRun <giannicarabelli@gmail.com>
Date: 2015-03-15 (Sun, 15 Mar 2015)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
2015-03-23 15:23:21 +01:00

57 lines
1.4 KiB
Perl
Executable File

#! /usr/bin/perl
# This proggie takes a (possibly outdated) locale file as its (only)
# argument, and creates a new version, with `-work` appended. The thus
# created tile contains all keys of the master file, and is intended
# to, after manual editing, replace the outdated locale file.
# Written by Barf on 2005-12-10.
$masterfilename = "english.locale";
$#ARGV == 0 || die("Usage: create-locals-work file.locale.");
$no_errors = 0;
$last_was_ok = 1;
$localefilename = @ARGV[0];
$outfilename = $localefilename . "-work";
open(masterfile, $masterfilename) || die("Could not open master file");
open(localefile, $localefilename) || die("Could not open locale file");
open(outfile, ">" . $outfilename) || die("Could not open output file");
%master = {};
%locale = {};
while (<masterfile>) {
# master hash
$line = $_;
($key) = /([^ ]+)/;
($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
$master{$key} = $text;
}
while (<localefile>) {
# locale hash
$line = $_;
($key) = /([^ ]+)/;
($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
$locale{$key} = $text;
}
foreach $term (sort keys %master) {
if (exists $locale{$term}) {
print outfile $term, " ", $locale{$term}, "\n";
} else {
# not found
$no_errors++;
print outfile $term, " TRANSLATE ", $master{$term}, "\n";
}
}
if ($no_errors == 0) {}
unlink($outfilename);
} else {
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
}