[Debian-l10n-commits] r1809 - in /dl10n/trunk: Changelog dl10n-pts

nekral-guest at users.alioth.debian.org nekral-guest at users.alioth.debian.org
Thu Jul 23 11:23:54 UTC 2009


Author: nekral-guest
Date: Thu Jul 23 11:23:53 2009
New Revision: 1809

URL: http://svn.debian.org/wsvn/?sc=1&rev=1809
Log:
	* dl10n-pts: Only display the categories where a PO file exist.

Modified:
    dl10n/trunk/Changelog
    dl10n/trunk/dl10n-pts

Modified: dl10n/trunk/Changelog
URL: http://svn.debian.org/wsvn/dl10n/trunk/Changelog?rev=1809&op=diff
==============================================================================
--- dl10n/trunk/Changelog (original)
+++ dl10n/trunk/Changelog Thu Jul 23 11:23:53 2009
@@ -1,3 +1,7 @@
+2009-07-23  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* dl10n-pts: Only display the categories where a PO file exist.
+
 2009-07-23  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* dl10n-pts: Provide some help to the maintainer on how they can

Modified: dl10n/trunk/dl10n-pts
URL: http://svn.debian.org/wsvn/dl10n/trunk/dl10n-pts?rev=1809&op=diff
==============================================================================
--- dl10n/trunk/dl10n-pts (original)
+++ dl10n/trunk/dl10n-pts Thu Jul 23 11:23:53 2009
@@ -123,6 +123,7 @@
 
 my %score;
 my %errors;
+my %langs;
 foreach my $pkg ($data->list_packages()) {
     next if defined $ignored_pkgs{$pkg};
 
@@ -132,26 +133,27 @@
             foreach my $line (@{$data->$part($pkg)}){
                 my ($pofile, $lang, $stat) = @{$line};
                 if (defined $lang and length $lang) {
-                    $score{$pkg}{$lang}{$part} =
-                        add_stat($stat, $score{$pkg}{$lang}{$part});
+                    $score{$pkg}{$part}{$lang} =
+                        add_stat($stat, $score{$pkg}{$part}{$lang});
+                    $langs{$pkg}{$lang} = 1;
                 }
             }
 
-            unless (defined $score{$pkg}{'_'}{$part}) {
+            unless (defined $score{$pkg}{$part}{'_'}) {
                 # If there is no POT file, try to find the number of strings
                 # from the other POs. This is usually a sign for non up to date
                 # PO files, so the number of strings in the PO files may vary.
                 # I choose to take the greatest number.
                 my $t = 0;
-                foreach my $lang (keys %{$score{$pkg}}) {
-                    if (    (defined $score{$pkg}{$lang}{$part})
-                        and (tot($score{$pkg}{$lang}{$part}) > $t)) {
-                        $t = tot($score{$pkg}{$lang}{$part});
+                foreach my $lang (keys %{$langs{$pkg}}) {
+                    if (    (defined $score{$pkg}{$part}{$lang})
+                        and (tot($score{$pkg}{$part}{$lang}) > $t)) {
+                        $t = tot($score{$pkg}{$part}{$lang});
                     }
                 }
-                $score{$pkg}{'__'}{$part} = "0t0f".$t."u";
+                $score{$pkg}{$part}{'__'} = "0t0f".$t."u";
             } else {
-                $score{$pkg}{'__'}{$part} = $score{$pkg}{'_'}{$part};
+                $score{$pkg}{$part}{'__'} = $score{$pkg}{$part}{'_'};
             }
         }
     }
@@ -165,21 +167,22 @@
 
 my %global_score;
 foreach my $pkg (keys %score) {
-    foreach my $lang (keys %{$score{$pkg}}) {
+    foreach my $lang (keys %{$langs{$pkg}}) {
         if ($lang ne "_" and $lang ne "__") {
-            foreach my $part (keys %{$score{$pkg}{$lang}}) {
+            foreach my $part (keys %{$score{$pkg}}) {
+                next unless defined $score{$pkg}{$part}{$lang};
                 if ($part eq "podebconf") {
                     $global_score{$pkg}{debian} =
-                        add_stat ($score{$pkg}{$lang}{$part},
+                        add_stat ($score{$pkg}{$part}{$lang},
                                   $global_score{$pkg}{debian});
                 } elsif ($part eq "po") {
                     # FIXME: use heuristics or control field
                     $global_score{$pkg}{nondebian} =
-                        add_stat ($score{$pkg}{$lang}{$part},
+                        add_stat ($score{$pkg}{$part}{$lang},
                                   $global_score{$pkg}{nondebian});
                 } elsif ($part eq "po4a") {
                     $global_score{$pkg}{debian} =
-                        add_stat ($score{$pkg}{$lang}{$part},
+                        add_stat ($score{$pkg}{$part}{$lang},
                                   $global_score{$pkg}{debian});
                 }
             }
@@ -259,18 +262,25 @@
     print PKGSTATUS <<EOF;
     <h1>Translation status of package $pkg</h1>
     <table>
-      <tr><th>Language</th><th>podebconf</th><th>po</th><th>po4a</th></tr>
 EOF
-    foreach my $lang (sort keys %{$score{$pkg}}) {
+    print PKGSTATUS "<tr><th>Language</th>";
+    print PKGSTATUS "<th>podebconf</th>"
+        if defined $score{$pkg}{"podebconf"};
+    print PKGSTATUS "<th>po</th>"
+        if defined $score{$pkg}{"po"};
+    print PKGSTATUS "<th>po4a</th>"
+        if defined $score{$pkg}{"po4a"};
+    print PKGSTATUS "</tr>\n";
+    foreach my $lang (sort keys %{$langs{$pkg}}) {
         if ($lang ne "_" and $lang ne "__") {
-            print PKGSTATUS "      ".
-                            "<tr><td align=\"right\">$lang</td><td>".
-                            graph_stats($score{$pkg}{$lang}{"podebconf"}).
-                            "</td><td>".
-                            graph_stats($score{$pkg}{$lang}{"po"}).
-                            "</td><td>".
-                            graph_stats($score{$pkg}{$lang}{"po4a"}).
-                            "</td></tr>\n";
+            print PKGSTATUS "      <tr><td align=\"right\">$lang</td>";
+            print PKGSTATUS "<td>".graph_stats($score{$pkg}{"podebconf"}{$lang})."</td>"
+                if defined $score{$pkg}{"podebconf"};
+            print PKGSTATUS "<td>".graph_stats($score{$pkg}{"po"}{$lang})."</td>"
+                if defined $score{$pkg}{"po"};
+            print PKGSTATUS "<td>".graph_stats($score{$pkg}{"po4a"}{$lang})."</td>"
+                if defined $score{$pkg}{"po4a"};
+            print PKGSTATUS "</tr>\n";
         }
     }
     print PKGSTATUS <<EOF;




More information about the Debian-l10n-commits mailing list