]> git.lyx.org Git - features.git/commitdiff
Have pocheck.pl check for missing arguments, like %1$s, etc.
authorRichard Heck <rgheck@comcast.net>
Tue, 5 Apr 2011 22:11:06 +0000 (22:11 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 5 Apr 2011 22:11:06 +0000 (22:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38263 a592a061-630c-0410-9148-cb99ea01b6c8

po/pocheck.pl

index dbbf1935d13318087737897640f79c4b98460085..0b2c0eda3c8bd13137cf0f3ace2f25eec8be11e5 100755 (executable)
@@ -45,7 +45,7 @@ foreach $pofilename ( @ARGV )
       $msgid = $msgid . $more;
       $i++;
     }
-
+    
     # now look for the associated msgstr.
     until ( ( $msgstr ) = ( $pofile[$i] =~ m/^msgstr "(.*)"/ ) ) { $i++; };
     $i++;
@@ -60,6 +60,25 @@ foreach $pofilename ( @ARGV )
     # (surely that is always $msgstr?)
     next if ($msgid eq "" or $msgstr eq "");
 
+    # Check for matching %1$s, etc.
+    @argstrs = ( $msgid =~ m/%(\d)\$s/g );
+    if (@argstrs) {
+      $num = 0;
+      foreach $arg (@argstrs) { $num = $arg if $arg > $num; }
+      if ($num <= 0) { 
+        print "Problem finding arguments in:\n    $msgid!\n";
+        $warn++;
+      } else {
+        foreach $i (1..$num) {
+          $arg = "%$i\\\$s"; 
+          if ( $msgstr !~ m/$arg/ ) {
+            print "Missing argument `$arg'\n  '$msgid' ==> '$msgstr'\n";
+            $warn++;
+          }
+        }
+      }
+    }
+
     # Check colon at the end of a message
     if ( ( $msgid =~ m/: *(\|.*)?$/ ) != ( $msgstr =~ m/: *(\|.*)?$/ ) ) {
       print( "Missing or unexpected colon:\n" );
@@ -94,7 +113,7 @@ foreach $pofilename ( @ARGV )
       print( "  '$msgid' => '$msgstr'\n" );
       $warn++;
     }
-
+    
     # we now collect these translations in a hash.
     # this will allow us to check below if we have translated
     # anything more than one way.