[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

New diff to transmonitor-check (for w.d.o/intl/l10n)



Hello,

I should send this directly to Denis, but I do this publicly, hopping that
other people get interest in this and get involved ;)

Here is a patch against
<webwml>/english/international/l10n/scripts/transmonitor-check
This script is the one which extracts the information about l10n (and a bit
of i18n) used to generate the web pages under w.d.o/intl/l10n.

The patch is about parsing the error messages from msgfmt, to rationalize a
bit what is stored in the DB, so that we can afterward do a page like
  http://www.debian.org/intl/l10n/templates/errors-by-pkg
for the po and po-debconf pages.

The next step would be to change the Errors: field of the DB to an array in
the same spirit of the PO: or PODEBCONF: fields, so that it becomes possible
to access all errors about a given file when generating the webpages about
one language. 
But not all the $data->add_error() calls are ready for that.

Anyway, this patch should help moving forward...


The patch also remove the line "$type = 'podebconf' unless $type eq 'po';"
which may reveal dangerous when we add other kind of informations in the DB.


Any comment?

Mt.

-- 
Le sens commun n'est pas si commun.
  -- Voltaire
[Common sense is not so common]
  
Index: scripts/transmonitor-check
===================================================================
RCS file: /cvs/webwml/webwml/english/international/l10n/scripts/transmonitor-check,v
retrieving revision 1.43
diff -u -r1.43 transmonitor-check
--- scripts/transmonitor-check	3 Sep 2003 22:14:52 -0000	1.43
+++ scripts/transmonitor-check	10 Sep 2003 14:43:51 -0000
@@ -625,8 +625,6 @@
         my $pkg = shift;
         my $file = shift;
         my $type = shift;
-        $type = 'podebconf' unless $type eq 'po';
-        $type = 'add_'.$type;
 
         my $filename; #the po file name to be archived
         my $lang=""; # the identified code language
@@ -667,13 +665,49 @@
                 ($this_stat, $err_msg) = read_stats("msgfmt --statistics -o /dev/null $PO_DIR/$filename 2>&1 1>/dev/null");
                 if ($err_msg ne '') {
                         $err_msg =~ s,\Q$PO_DIR/$filename\E,$file,g;
-                        $data->add_errors($pkg, "gettext: ".$err_msg);
+		        my @err_msg = split(/\n/,$err_msg);
+		        foreach my $line (@err_msg) {
+			    # syntax po file error
+			    if ($line =~ m/end-of-line within string/) {
+				$data->add_errors($pkg, "$type: $file: end-of-line-within-string");
+			    } elsif ($line =~ m/duplicate message definition/) {
+				$data->add_errors($pkg, "$type: $file: duplicate-message-definition");
+				shift @err_msg;
+			    } elsif ($line =~ m/invalid control sequence/) {
+				$data->add_errors($pkg, "$type: $file: invalid-control-sequence");
+			    } elsif ($line =~ m/keyword.*?unknown/ || 
+				$line =~ m/parse error/ ||
+				$line =~ m/missing .*? section/) {
+				$data->add_errors($pkg, "$type: $file: parse-error");
+			    }
+			    # encoding errors
+			    elsif ($line =~ m/Charset "([^"]*)" is not a portable encoding name/ ||) { # "
+		                $line =~ m/Charset missing in header/) {
+				$data->add_errors($pkg, "$type: $file: $1: non-portable-encoding-name");
+			    }		
+	                    elsif ($line =~ m/invalid multibyte sequence/) {
+				$data->add_errors($pkg, "$type: $file: invalid-multibyte-sequence");
+			    }				
+	                    # simple checking rules
+	                    elsif ($line =~ m/.msgid. and .msgstr. entries do not both end with ..n/) {
+				$data->add_errors($pkg, "$type: $file: msgid-and-msgstr-format-mismatch");				
+			    }
+	                    # other errors
+			    elsif ($line =~ m/msgfmt: too many errors, aborting/) {
+				$data->add_errors($pkg, "$type: $file: too-many-errors");
+			    }
+			    elsif ($line =~ m/msgfmt: found [0-9]* fatal errors/) {}
+	                    # Unknown error
+	                    else {
+				$data->add_errors($pkg, "$type: $file: unknown-error: $line");
+			    }
+			}	   
                 }
         } else { # no valid lang found
                 if ($bad_lang eq "") {
-                        $data->add_errors($pkg, "gettext: $file: can't guess language");
+                        $data->add_errors($pkg, "$type: $file: cannot-guess-language");
                 } else {
-                        $data->add_errors($pkg, "gettext: $file: $bad_lang not a language code");
+                        $data->add_errors($pkg, "$type: $file: $bad_lang: not-a-language-code");
                 }
         }
         # Add this file to the data
@@ -697,6 +731,7 @@
         }
 
         # Add this file to the data
+        $type = 'add_'.$type;
         $data->$type($pkg, $file, normalize_lang($lang), $this_stat, $filename, $lasttrans, $langteam);
         if (system("gzip -9f $PO_DIR/$filename")) {
                 warn "Can't gzip $PO_DIR/$filename: $!\n";

Reply to: