changeset 9531:06fe6ed7f63a

[gaim-migrate @ 10358] "How do you update your po files ("make update-po" or ./update.pl)? update.pl has some advantages. But update.pl has also a small bug. In rare cases (double msgid's etc.) update.pl kills your po-file. This can happen, if msgmerge fails and if you have an old gettext version. The problem is here: po/update.pl:149: ... $d="mv $LANG.po $LANG.po.old && msgmerge $LANG.po.old $PACKAGE.pot -o +$LANG.po"; ... If msgmerge fails, the file $LANG.po will be overwritten. "make update-po" has not this problem, because it uses a temporary file: ... if $(MSGMERGE) $$lang.po $(PACKAGE).pot -o $$lang.new.po; then \ mv -f $$lang.new.po $$lang.po; \ else \ echo "msgmerge for $$cat failed!"; \ rm -f $$lang.new.po; \ fi; \ ... I patched po/update.pl. Now it uses a temporary file. Also, update2.pl lists files in po/POTFILES.in which have no i18n strings as a warning." -- Bjoern Voigt committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 14 Jul 2004 20:14:48 +0000
parents 78f9641ad4e5
children b27ab1b8395d
files po/update.pl
diffstat 1 files changed, 106 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/po/update.pl	Wed Jul 14 20:12:42 2004 +0000
+++ b/po/update.pl	Wed Jul 14 20:14:48 2004 +0000
@@ -4,6 +4,7 @@
 #  (C) 2000 The Free Software Foundation
 #
 #  Author(s): Kenneth Christiansen
+#  Patches:   Björn Voigt <bjoern@cs.tu-berlin.de>
 
 
 $VERSION = "1.2.5 beta 2";
@@ -51,48 +52,58 @@
           ." --files-from\=\.\/POTFILES\.in ";
         $b1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
            ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
-         
-        `$b`;
-        `$b1`;
+        print $b . "\n"; 
+	if(($ret=system($b . " && " . $b1))==0) {
+	    print "...done\n";
+	}
+	else {
+	    print "...failed\n";
+	}
 
-        print "...done\n";
-
-        exit;
+        exit $ret;
     }
         
     elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){
 
-        $a="find ../ -print | egrep '.*\\.(c|y|cc|c++|h|gob)' ";
+        $a="find ../ -path ../intl -prune -o -print | egrep '.*\\.(c|y|cc|c++|h|gob)\$' ";
 
         open(BUF2, "POTFILES.in") || die "update.pl:  there's not POTFILES.in!!!\n";
-        print "Searching for missing _(\" \") entries...\n";
+        print "Searching for missing _(\" \") entries and for deleted files...\n";
         open(BUF1, "$a|");
 
 
         @buf2 = <BUF2>;
         @buf1 = <BUF1>;
 
-        if (-s "POTFILES.ignore"){
+        if (-s "POTFILES.ignore") {
             open FILE, "POTFILES.ignore";
             while (<FILE>) {
-                if ($_=~/^[^#]/o){
+                if ($_=~/^[^#]/o) {
                     push @bup, $_;
                 }
             }
             print "POTFILES.ignore found! Ignoring files...\n";
 	    @buf2 = (@bup, @buf2);
-        }
+	    }
 
-        foreach my $file (@buf1){
-            open FILE, "<$file";
-            while (<FILE>) {
-                if ($_=~/_\(\"/o){
-                    $file = unpack("x3 A*",$file) . "\n";
-                    push @buff1, $file;
-                    last;
-                }
-            }
-        }
+        foreach my $file (@buf1) {
+	    $cmd="xgettext -o - --omit-header --keyword=_ " .
+		"--keyword=N_ " . $file . " |";
+	    open XGET, $cmd;
+	    if(<XGET>) {
+		$file = unpack("x3 A*",$file) . "\n";
+		push @buff1, $file;
+	    }
+	    close XGET;
+#	    open FILE, "<$file";
+#            while (<FILE>) {
+#                if ($_=~/_\(\"/o || $_=~/ngettext\(\"/o){
+#                    $file = unpack("x3 A*",$file) . "\n";
+#                    push @buff1, $file;
+#                    last;
+#                }
+#            }
+	}
 
         @bufff1 = sort (@buff1);
 
@@ -100,24 +111,74 @@
 
         my %in2;
         foreach (@bufff2) {
+	    chomp;
             $in2{$_} = 1;
         }
 
-        foreach (@bufff1){
-            if (!exists($in2{$_})){
-                push @result, $_ }
-            }
+        my %in1;
+        foreach (@bufff1) {
+	    chomp;
+            $in1{$_} = 1;
+        }
+
+        foreach (@bufff1) {
+	    chomp;
+            if (!exists($in2{$_})) {
+                push @result, $_ . "\n";
+	    }
+	}
+
+        foreach (@bufff2) {
+	    chomp;
+            if (! -f "../" . $_) {
+                push @deletedfiles, $_ . "\n"; 
+	    }
+	}
+	
+	foreach (@bufff2) {
+	    if (!exists($in1{$_})) {
+		push @noi18nfiles, $_ . "\n";
+	    }
+	}
 
         if(@result){
             open OUT, ">POTFILES.in.missing";
             print OUT @result;
-            print "\nHere are the results:\n\n", @result, "\n";
+            print "\nHere are the missing files:\n\n", @result, "\n";
             print "File POTFILES.in.missing is being placed in directory...\n";
             print "Please add the files that should be ignored in POTFILES.ignore\n";
         }
         else{
+	    unlink("POTFILES.in.missing");
+        }
+	    
+        if(@deletedfiles){
+            open OUT, ">POTFILES.in.deleted";
+            print OUT @deletedfiles;
+            print "\nHere are the deleted files:\n\n", @deletedfiles, "\n";
+            print "File POTFILES.in.deleted is being placed in directory...\n";
+            print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
+        }
+        else{
+	    unlink("POTFILES.in.deleted");
+        }
+
+        if(@noi18nfiles){
+            open OUT, ">POTFILES.in.noi18n";
+            print OUT @noi18nfiles;
+            print "\nHere are the files which currently have no i18n strings:\n\n", 
+	    @noi18nfiles, "\n";
+            print "File POTFILES.in.noi18n is being placed in directory...\n";
+            print "Please delete the files from POTFILES.in or POTFILES.ignore\n";
+	    print "or ignore the files.\n";
+        }
+        else{
+	    unlink("POTFILES.in.noi18n");
+        }
+
+        if( ! @result && ! @deletedfiles ) {
             print "\nWell, it's all perfect! Congratulation!\n";
-        }         
+        }
     }
 
 
@@ -138,25 +199,29 @@
     $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
        ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";
 
-    `$c`;
-    `$c1`;
+    if(($ret=system($c . " && " . $c1))==0) {
+	print "...done\n";
+    }
+    else {
+	print "...failed\n";
+    }
 
-    print "...done";
-
-    print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
+    if($ret==0) {
+	print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n";
 
     
-    $d="mv $LANG.po $LANG.po.old && msgmerge $LANG.po.old $PACKAGE.pot -o $LANG.po";
-
-    $f="msgfmt --statistics $LANG.po";
+	$d="if msgmerge $LANG.po $PACKAGE.pot -o $LANG.new.po; then " .
+	    "  mv -f $LANG.new.po $LANG.po; " .
+	    "  msgfmt --statistics  -c -v -o /dev/null $LANG.po; " .
+	    "else " .
+	    "  echo \"msgmerge failed!\"; " .
+	    "  rm -f $LANG.new.po; ".
+	    "fi";
 
-    `$d`;
-    `$f`;
+	$ret=system($d);
 
-    unlink "messages";
-    unlink "$LANG.po.old";
-
-    exit;
+	exit $ret;
+    }
 }
 
 else{