version 1.9, 2009/01/13 12:31:13
|
version 1.10, 2009/01/13 16:46:35
|
Line 15 my $numbered=0;
|
Line 15 my $numbered=0;
|
# 1: add, 0: don't add |
# 1: add, 0: don't add |
my $helper=0; |
my $helper=0; |
|
|
|
# Debug Mode |
|
# Displays additional output for debugging purposes |
|
my $debug=0; |
|
|
|
|
# ---------------------------------------------------------------- |
# ---------------------------------------------------------------- |
# ----- Sub Routines ----- |
# ----- Sub Routines ----- |
Line 40 sub readnew {
|
Line 44 sub readnew {
|
while (my $line=<IN>) { |
while (my $line=<IN>) { |
chomp($line); |
chomp($line); |
$lexicon{$line}=$line; |
$lexicon{$line}=$line; |
|
print " New entry: $line\n" if $debug; |
} |
} |
close(IN); |
close(IN); |
return %lexicon; |
return %lexicon; |
Line 48 sub readnew {
|
Line 53 sub readnew {
|
|
|
# ---------------------------------------------------------------- |
# ---------------------------------------------------------------- |
# ----- Main Program ----- |
# ----- Main Program ----- |
|
|
my %master=&readnew(); |
|
my $i; |
my $i; |
my $num; |
my $num; |
my $dlm; |
my $dlm; |
my $comment; |
my $comment; |
|
|
|
print "*** Synching Translation Files ***\n"; |
|
|
|
# Create master hash for the entire set of all translations |
|
print "Building master hash:\n"; |
|
|
|
# Initialy fill master hash with phrases which are additionally needed/wanted. |
|
print " Adding new phrases... "; |
|
my %master=&readnew(); |
|
print "ok.\n"; |
|
|
|
# Add all the different phrases of all translation files to master hash |
foreach (<*.pm>) { |
foreach (<*.pm>) { |
print "Reading: ".$_."\n"; |
print " Reading ".$_." ... "; |
%master=(%master,&readlexicon($_)); |
%master=(%master,&readlexicon($_)); |
|
print "ok.\n"; |
} |
} |
|
|
# Remove obsolete from synch |
# Ignore all phrases found in removephrases.txt for current synchronization. |
# Ignore all phrases in removephrases.txt for current synchronization |
# These phrases would not be removed from a translation file, if they existed in the file. |
|
# But the phrases will not be added to any translation file even if they were missing in it. |
|
# Remove these obsolete phrases from master hash |
|
print " Removing obsolete phrases... "; |
open(IN,'removephrases.txt'); |
open(IN,'removephrases.txt'); |
while (my $line=<IN>) { |
while (my $line=<IN>) { |
chomp($line); |
chomp($line); |
delete $master{$line}; |
delete $master{$line}; |
} |
} |
close(IN); |
close(IN); |
|
print "ok.\n"; |
|
|
|
|
|
print "Synchronization:\n"; |
foreach my $fn (<*.pm>) { |
foreach my $fn (<*.pm>) { |
print "Synching: ".$fn."\n"; |
print " Synching ".$fn." ... "; |
|
# Build hash with all translations of current translation file |
my %lang=&readlexicon($fn); |
my %lang=&readlexicon($fn); |
|
# Copy current translation file so that the old file could be overwritten with the new content |
|
# while the copy is used to read from. |
system ("cp $fn $fn.original"); |
system ("cp $fn $fn.original"); |
open(IN,$fn.'.original'); |
open(IN,$fn.'.original'); |
|
# Rebuild current translation file |
|
# by writing all exisiting entries until SYNCMARKER |
open(OUT,'>'.$fn); |
open(OUT,'>'.$fn); |
my $found=0; |
my $found=0; |
# Rebuild current translation file until SYNCMARKER: |
|
while (<IN>) { |
while (<IN>) { |
if ($_=~/\#\s*SYNCMARKER/) { $found=1; last; } |
if ($_=~/\#\s*SYNCMARKER/) { $found=1; last; } |
print OUT $_; |
print OUT $_; |
} |
} |
|
# Append missing phrases to new version of current translation file |
|
# by synching old version of current translation file with master hash |
if ($found) { |
if ($found) { |
$i=0; |
$i=0; |
print OUT "\n\#SYNC ".localtime()."\n"; |
print OUT "\n\#SYNC ".localtime()."\n"; |
Line 89 foreach my $fn (<*.pm>) {
|
Line 115 foreach my $fn (<*.pm>) {
|
foreach my $key (sort keys %master) { |
foreach my $key (sort keys %master) { |
unless ($key) { next; } |
unless ($key) { next; } |
unless ($lang{$key}) { |
unless ($lang{$key}) { |
|
print " Found to be added: $key\n" if $debug; |
if ($helper) { |
if ($helper) { |
$comment=''; |
$comment=''; |
my $copytrans=$key; |
my $copytrans=$key; |
Line 135 ENDNEW
|
Line 162 ENDNEW
|
} |
} |
close (IN); |
close (IN); |
close (OUT); |
close (OUT); |
|
print"ok.\n"; |
} |
} |
|
print "Synchronization completed.\n"; |
|
|