-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmergeLS
executable file
·53 lines (46 loc) · 1.08 KB
/
mergeLS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
#
# Created 2005/02/08 by Simon Urbanek
$tar=shift;
$src=shift;
if ($tar eq '' || $src eq '') {
print "\n Usage: mergeLS <master> <localized>\n\nMerges translations from <localized> into <master> and replaces <localized>.\n\n";
exit 0;
}
print " Loading $src ...\n";
open IN, $src || die "Cannot open $src file.\n";
while(<IN>) {
s/[\r\n]+//g;
if (/^\"(.*?)\"\s*=\s*\"(.*?)\";$/) {
$key{$1}=$2;
}
}
close IN;
@k=keys %key; $ks=$#k; $ks++;
print " $ks strings loaded.\n";
open IN, $tar || die "Cannot open $tar file.\n";
open OUT, ">tmp.merge.loc.strings" || die "Cannot open temporary file tmp.merge.loc.strings.";
while (<IN>) {
s/[\r\n]+//g;
if (/^\"(.*?)\"\s*=\s*\"(.*?)\";$/) {
$val = $2;
if ($key{$1} ne '') {
$val = $key{$1};
$used{$1}++;
}
print OUT "\"$1\" = \"$val\";\n";
} else {
print OUT "$_\n";
}
}
close IN;
close OUT;
system "mv tmp.merge.loc.strings \"$src\"";
foreach (sort keys %key) {
push @uk, $_ if ($used{$_}==0);
}
if ($uk[0] ne '') {
print " ** Unused keys: ", (join ', ', @uk), "\n";
} else {
print " All keys merged.\n";
}