[LON-CAPA-cvs] cvs: loncom /localize/localize synch.pl

bisitz bisitz@source.lon-capa.org
Wed, 09 Dec 2009 10:30:45 -0000


bisitz		Wed Dec  9 10:30:45 2009 EDT

  Modified files:              
    /loncom/localize/localize	synch.pl 
  Log:
  - Ignore emtpy rows in newphrases.txt and removephrases.txt
  - Added some comments
  - Optimized quotation warning message
  
  
Index: loncom/localize/localize/synch.pl
diff -u loncom/localize/localize/synch.pl:1.13 loncom/localize/localize/synch.pl:1.14
--- loncom/localize/localize/synch.pl:1.13	Wed Jun  3 16:33:15 2009
+++ loncom/localize/localize/synch.pl	Wed Dec  9 10:30:45 2009
@@ -26,7 +26,8 @@
 # If you want to exclude translation files from being included
 # in the synching process, remove their file names from this list.
 my @listoffiles=(
-       'ar.pm'
+#      'test.pm'
+      ,'ar.pm'
       ,'de.pm'
       ,'es.pm'
       ,'fa.pm'
@@ -77,8 +78,9 @@
     open(IN,'newphrases.txt') or die;
     my %lexicon=();
     while (my $line=<IN>) {
-	chomp($line);
-	$lexicon{$line}=$line;
+        chomp($line);
+        next if ($line eq '');
+        $lexicon{$line}=$line;
         print "    New entry: '$line'\n" if $debug;
     }
     close(IN);
@@ -97,9 +99,9 @@
 
 # ----------------------------------------------------------------
 # ----- Main Program -----
-my $i;
+my $i; # Count new phrases
 my $num;
-my $dlm;
+my $dlm; # Delimiter character
 my $comment;
 
 print "*** Synching Translation Files ***\n";
@@ -131,6 +133,7 @@
 my $rm=0;
 while (my $line=<IN>) {
     chomp($line);
+    next if ($line eq '');
     delete $master{$line};
     $rm++;
 }
@@ -165,7 +168,7 @@
         # Sync master with current translation file:
 	foreach my $key (sort keys %master) {
 	    print "\n    Checking key: '$key'" if $debug;
-	    unless ($key) { next; }
+	    next unless ($key);
 	    unless ($lang{$key}) {
                 # Translation helper?
                 if ($helper) {
@@ -187,10 +190,10 @@
 		    $num='';
 		}
                 # Find delimiter for key and value
-		if (($key=~/\'/) & ($key=~/\"/)) {
-		    $quotwarn++;
-		    print " Warning: Both, ' and \",occur!" if $debug;
-		}
+                if (($key=~/\'/) & ($key=~/\"/)) {
+                    $quotwarn++;
+                    print " (Warning: Both, ' and \", occur!)" if $debug;
+                }
 		# if (($key=~/[^\\]\'/) | ($key=~/\\\"/)) {
 		if ($key=~/\'/) {
 		    $dlm='"';