mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
locale: fix "make work-locals"
* let the makefile work with out-of-tree builds to some extent
* rework the create-locals-work skript to be more perl-ish, use
warnings and strict to see bugs easily.
Origin commit data
------------------
Branch: ni/coolstream
Commit: ea19964ec3
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2016-01-03 (Sun, 03 Jan 2016)
Origin message was:
------------------
locale: fix "make work-locals"
* let the makefile work with out-of-tree builds to some extent
* rework the create-locals-work skript to be more perl-ish, use
warnings and strict to see bugs easily.
------------------
This commit was generated by Migit
This commit is contained in:
@@ -38,7 +38,7 @@ sort-locals:
|
|||||||
|
|
||||||
work-locals: $(master.locale)
|
work-locals: $(master.locale)
|
||||||
for locale in $(locale); do \
|
for locale in $(locale); do \
|
||||||
$(top_srcdir)/data/locale/helpers/create-locals-work $${locale}; \
|
( cd $(top_srcdir)/data/locale; helpers/create-locals-work $${locale}; ); \
|
||||||
done
|
done
|
||||||
|
|
||||||
ordercheck: $(master.locale)
|
ordercheck: $(master.locale)
|
||||||
|
@@ -6,50 +6,60 @@
|
|||||||
# to, after manual editing, replace the outdated locale file.
|
# to, after manual editing, replace the outdated locale file.
|
||||||
|
|
||||||
# Written by Barf on 2005-12-10.
|
# Written by Barf on 2005-12-10.
|
||||||
|
# reorganized by Stefan Seyfried 2016-01-03, following changes:
|
||||||
|
# * use strict, use warnings to find errors easier
|
||||||
|
# * make it work with the above pragmas
|
||||||
|
# * tolerance against empty locales in english.locale
|
||||||
|
|
||||||
$masterfilename = "english.locale";
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $masterfilename = "english.locale";
|
||||||
|
|
||||||
$#ARGV == 0 || die("Usage: create-locals-work file.locale.");
|
$#ARGV == 0 || die("Usage: create-locals-work file.locale.");
|
||||||
|
|
||||||
$no_errors = 0;
|
my $no_errors = 0;
|
||||||
$last_was_ok = 1;
|
my $last_was_ok = 1;
|
||||||
$localefilename = @ARGV[0];
|
my $localefilename = $ARGV[0];
|
||||||
$outfilename = $localefilename . "-work";
|
my $outfilename = $localefilename . "-work";
|
||||||
|
|
||||||
open(masterfile, $masterfilename) || die("Could not open master file");
|
open(MASTER, $masterfilename) || die("Could not open master file $masterfilename");
|
||||||
open(localefile, $localefilename) || die("Could not open locale file");
|
open(LOCALE, $localefilename) || die("Could not open locale file $localefilename");
|
||||||
open(outfile, ">" . $outfilename) || die("Could not open output file");
|
open(OUT, ">" . $outfilename) || die("Could not open output file $outfilename");
|
||||||
|
|
||||||
%master = {};
|
my %master;
|
||||||
%locale = {};
|
my %locale;
|
||||||
|
|
||||||
while (<masterfile>) {
|
my $line;
|
||||||
|
while ($line = <MASTER>) {
|
||||||
# master hash
|
# master hash
|
||||||
$line = $_;
|
chomp $line;
|
||||||
($key) = /([^ ]+)/;
|
$line =~ s/^\s+//; # strip whitespace from start of line
|
||||||
($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
|
my ($key, $text) = split /\s+/, $line, 2;
|
||||||
$master{$key} = $text;
|
$master{$key} = $text ? $text : "";
|
||||||
}
|
}
|
||||||
|
close(MASTER);
|
||||||
|
|
||||||
while (<localefile>) {
|
while ($line = <LOCALE>) {
|
||||||
# locale hash
|
# locale hash
|
||||||
$line = $_;
|
chomp $line;
|
||||||
($key) = /([^ ]+)/;
|
$line =~ s/^\s+//;
|
||||||
($junk, $text) = /([^ ]+)[ ]+([^\n]+)/;
|
my ($key, $text) = split /\s+/, $line, 2;
|
||||||
$locale{$key} = $text;
|
$locale{$key} = $text ? $text : "";
|
||||||
}
|
}
|
||||||
|
close(LOCALE);
|
||||||
|
|
||||||
foreach $term (sort keys %master) {
|
foreach my $term (sort keys %master) {
|
||||||
if (exists $locale{$term}) {
|
if (exists $locale{$term}) {
|
||||||
print outfile $term, " ", $locale{$term}, "\n";
|
print OUT $term." ".$locale{$term}."\n";
|
||||||
} else {
|
} else {
|
||||||
# not found
|
# not found
|
||||||
$no_errors++;
|
$no_errors++;
|
||||||
print outfile $term, " TRANSLATE ", $master{$term}, "\n";
|
print OUT $term." TRANSLATE ".$master{$term}."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($no_errors == 0) {}
|
if ($no_errors == 0) {
|
||||||
unlink($outfilename);
|
unlink($outfilename);
|
||||||
} else {
|
} else {
|
||||||
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
|
print "There were ", $no_errors, " error(s) in ", $localefilename, ".\n";
|
||||||
|
Reference in New Issue
Block a user