Le jeudi 06 août 2009 à 16:54 +0200, Julien Valroff a écrit :
> Hi again,
> 
> Le jeudi 06 août 2009 à 09:51 +0200, Julien Valroff a écrit :
> > Hi,
> > 
> > As promised, I am working on the template translation into French.
> > 
> > Some strings are however hardcoded in the cgi ("Empty", "Administrative
> > suite")
> > 
> [...]
> 
> > I can provide a patch if this is a correct workaround, but would prefer
> > your feedback before.
> 
> I couldn't wait as I was impatient to test my translation...
> 
> Here is the patch proposal to remove hardcoded strings from the cgi, and
> load them from a strings.txt file.

I attach a new patch fixing an issue in the history page which prevented
mail to be retrained from the WebUI.

Cheers,
Julien
diff --git a/webui/cgi-bin/admin.cgi b/webui/cgi-bin/admin.cgi
index c4b3aa9..445d739 100755
--- a/webui/cgi-bin/admin.cgi
+++ b/webui/cgi-bin/admin.cgi
@@ -20,11 +20,16 @@
 
 use strict;
 use Time::Local;
-use vars qw { %CONFIG %DATA %FORM };
+use vars qw { %CONFIG %DATA %FORM %LANG };
 require "ctime.pl";
 
 # Read configuration parameters common to all CGI scripts
 require "configure.pl";
+if (-s "$CONFIG{'TEMPLATES'}/strings.txt") {
+	require "$CONFIG{'TEMPLATES'}/strings.txt";
+} else {
+	require "$CONFIG{'TEMPLATES'}/../strings.txt";
+}
 
 #
 # The current CGI script
@@ -47,7 +52,7 @@ do {
   close(FILE);
 
   if (!$admin) {
-    &error("Access Denied");
+    &error($LANG{'error_access_denied'});
   }
 };
 
@@ -82,7 +87,7 @@ if ($CONFIG{'AUTODETECT'} == 1 || $CONFIG{'AUTODETECT'} eq "") {
 %FORM = &ReadParse;
 
 if ($ENV{'REMOTE_USER'} eq "") { 
-  &error("System Error. I was unable to determine your identity.");
+  &error($LANG{'error_no_identity'});
 }
 
 if ($FORM{'template'} eq "" || $FORM{'template'} !~ /^([A-Z0-9]*)$/i) {
@@ -117,7 +122,7 @@ if ($FORM{'template'} eq "status") {
   &DisplayPreferences;
 }
 
-&error("Invalid Command $FORM{'COMMAND'}");
+&error("$LANG{'error_invalid_command'} $FORM{'COMMAND'}");
 
 #
 # Preferences Functions
@@ -213,7 +218,7 @@ sub DisplayPreferences {
         . quotemeta($FORM{'dailyQuarantineSummary'}) . "> /dev/null");
 
     } else {
-      open(FILE, ">$FILE") || do { &error("Unable to write preferences: $!"); };
+      open(FILE, ">$FILE") || do { &error("$LANG{'error_cannot_write_prefs'}: $!"); };
       print FILE <<_END;
 trainingMode=$FORM{'trainingMode'}
 spamAction=$FORM{'spamAction'}
@@ -386,7 +391,7 @@ sub DisplayStatus {
   my ($c_daily) = 0; 
 
   if (! -e $LOG) {
-    &error("No historical data is available.");
+    &error($LANG{'error_no_historic'});
   }
 
   # Initialize each individual time period
@@ -424,7 +429,7 @@ sub DisplayStatus {
     $block_weekly[$_]		= 0;
   }
 
-  open(LOG, "<$LOG") || &error("Unable to open logfile: $!");
+  open(LOG, "<$LOG") || &error("$LANG{'error_cannot_open_log'}: $!");
   while(<LOG>) {
     my($t_log, $c_log, $signature, $e_log) = (split(/\t/))[0,1,3,5];
     next if ($t_log > time);
@@ -736,10 +741,11 @@ sub error {
   my($error) = @_;
   $FORM{'template'} = "error";
   $DATA{'MESSAGE'} = <<_end;
-The following error occured while trying to process your request: <BR>
+$LANG{'error_message_part1'}
+<BR>
 <B>$error</B><BR>
 <BR>
-If this problem persists, please contact your administrator.
+$LANG{'error_message_part2'}
 _end
   &output(%DATA);
 }
@@ -825,7 +831,7 @@ sub GetPrefs {
     }
                                                                                 
     if (! -e $FILE) {
-      &error("Unable to load default preferences");
+      &error($LANG{'error_load_default_prefs'});
     }
                                                                                 
     open(FILE, "<$FILE");
diff --git a/webui/cgi-bin/admingraph.cgi b/webui/cgi-bin/admingraph.cgi
index d2eddd1..c067ede 100755
--- a/webui/cgi-bin/admingraph.cgi
+++ b/webui/cgi-bin/admingraph.cgi
@@ -21,10 +21,15 @@
 use CGI ':standard';
 use GD::Graph::bars;
 use strict;
-use vars qw { %CONFIG %FORM @spam @nonspam @period @data @inoc @sm @fp @wh @corpus @virus @black @block };
+use vars qw { %CONFIG %FORM %LANG @spam @nonspam @period @data @inoc @sm @fp @wh @corpus @virus @black @block };
 
 # Read configuration parameters common to all CGI scripts
 require "configure.pl";
+if (-s "$CONFIG{'TEMPLATES'}/strings.txt") {
+        require "$CONFIG{'TEMPLATES'}/strings.txt";
+} else {
+        require "$CONFIG{'TEMPLATES'}/../strings.txt";
+}
 
 %FORM = &ReadParse();
 
@@ -49,7 +54,7 @@ do {
 my $mygraph = GD::Graph::bars->new(500, 250);
 $mygraph->set(
     x_label     => "$FORM{'x_label'}",
-    y_label     => 'Number of Messages',
+    y_label     => "$LANG{'graph_legend_nb_messages'}",
     title       => "$FORM{'title'}",
     legend_placement => 'RT',
     legend_spacing => 2,
@@ -83,7 +88,9 @@ if ($CONFIG{'3D_GRAPHS'} == 1) {
 }
 
 $mygraph->set_legend_font(GD::gdMediumBoldFont);
-$mygraph->set_legend(' Inoculations',' Corpusfeds',' Virus',' Blacklisted (RBL)',' Blocklisted',' Auto-Whitelisted',' Spam', ' Nonspam',' Spam Misses',' False Positives');
+$mygraph->set_legend(" $LANG{'graph_legend_inoculations'}", " $LANG{'graph_legend_corpusfeds'}", " $LANG{'graph_legend_virus'}",
+	" $LANG{'graph_legend_RBL'}", " $LANG{'graph_legend_blocklisted'}", " $LANG{'graph_legend_whitelisted'}", " $LANG{'graph_legend_spam'}",
+	" $LANG{'graph_legend_nonspam'}", " $LANG{'graph_legend_spam_misses'}", " $LANG{'graph_legend_falsepositives'}");
 my $myimage = $mygraph->plot(\...@data) or die $mygraph->error;
                                                                                 
 print "Content-type: image/png\n\n";
diff --git a/webui/cgi-bin/dspam.cgi b/webui/cgi-bin/dspam.cgi
index d54c027..d23a38f 100755
--- a/webui/cgi-bin/dspam.cgi
+++ b/webui/cgi-bin/dspam.cgi
@@ -20,12 +20,17 @@
 
 use strict;
 use Time::Local;
-use vars qw { %CONFIG %DATA %FORM $MAILBOX $CURRENT_USER $USER $TMPFILE};
+use vars qw { %CONFIG %DATA %FORM %LANG $MAILBOX $CURRENT_USER $USER $TMPFILE};
 use vars qw { $CURRENT_STORE };
 require "ctime.pl";
 
 # Read configuration parameters common to all CGI scripts
 require "configure.pl";
+if (-s "$CONFIG{'TEMPLATES'}/strings.txt") {
+        require "$CONFIG{'TEMPLATES'}/strings.txt";
+} else {
+        require "$CONFIG{'TEMPLATES'}/../strings.txt";
+}
 
 if($CONFIG{"DATE_FORMAT"}) {
   use POSIX qw(strftime);
@@ -105,7 +110,7 @@ $MAILBOX = $USER . ".mbox";
 $TMPFILE = $USER . ".tmp";
 
 if ($CURRENT_USER eq "") {
-  &error("System Error. I was unable to determine your identity.");
+  &error($LANG{'error_no_identity'});
 }
 
 if ($FORM{'template'} eq "" || $FORM{'template'} !~ /^([A-Z0-9]*)$/i) {
@@ -185,7 +190,7 @@ if ($FORM{'template'} eq "performance") {
 } elsif ($FORM{'template'} eq "fragment") {
   &DisplayFragment;
 } else {
-  &error("Invalid Command $FORM{'COMMAND'}");
+  &error("LANG{'error_invalid_command'} $FORM{'COMMAND'}");
 }
 
 #
@@ -249,7 +254,7 @@ sub DisplayHistory {
 
   my($LOG) = "$USER.log";
   if (! -e $LOG) {
-    &error("No historical data is available");
+    &error($LANG{'error_no_historic'});
   }
 
   # Preseed retraining information and delivery errors
@@ -363,34 +368,34 @@ sub DisplayHistory {
 
     my($cl, $cllabel);
     $class = $rec{$signature}->{'class'} if ($rec{$signature}->{'class'} ne "");
-    if ($class eq "S") { $cl = "spam"; $cllabel="SPAM"; }
-    elsif ($class eq "I") { $cl = "innocent"; $cllabel="Good"; }
+    if ($class eq "S") { $cl = "spam"; $cllabel=$LANG{'history_label_spam'}; }
+    elsif ($class eq "I") { $cl = "innocent"; $cllabel=$LANG{'history_label_innocent'}; }
     elsif ($class eq "F") {
       if ($rec{$signature}->{'count'} % 2 != 0) {
-        $cl = "false"; $cllabel="Miss"; 
+        $cl = "false"; $cllabel=$LANG{'history_label_miss'};
       } else {
-        $cl = "innocent"; $cllabel="Good"; 
+        $cl = "innocent"; $cllabel=$LANG{'history_label_innocent'};
       }
     }
     elsif ($class eq "M") { 
       if ($rec{$signature}->{'count'} % 2 != 0) {
-          $cl = "missed"; $cllabel="Miss"; 
+          $cl = "missed"; $cllabel=$LANG{'history_label_miss'}; 
       } else {
-          $cl = "spam"; $cllabel="SPAM";
+          $cl = "spam"; $cllabel=$LANG{'history_label_spam';
       }
     }
-    elsif ($class eq "W") { $cl = "whitelisted"; $cllabel="Whitelist"; }
-    elsif ($class eq "V") { $cl = "virus"; $cllabel="Virus"; }
-    elsif ($class eq "A") { $cl = "blacklisted"; $cllabel="RBL"; }
-    elsif ($class eq "O") { $cl = "blocklisted"; $cllabel="BLOCK"; }
-    elsif ($class eq "N") { $cl = "inoculation"; $cllabel="SPAM"; }
-    elsif ($class eq "C") { $cl = "corpus"; $cllabel="Corpus"; }
-    elsif ($class eq "U") { $cl = "unknown"; $cllabel="UNKN"; }
-    elsif ($class eq "E") { $cl = "error"; $cllabel="Error"; }
+    elsif ($class eq "W") { $cl = "whitelisted"; $cllabel=$LANG{'history_label_whitelist'}; }
+    elsif ($class eq "V") { $cl = "virus"; $cllabel=$LANG{'history_label_virus'}; }
+    elsif ($class eq "A") { $cl = "blacklisted"; $cllabel=$LANG{'history_label_rbl'}; }
+    elsif ($class eq "O") { $cl = "blocklisted"; $cllabel=$LANG{'history_label_block'}; }
+    elsif ($class eq "N") { $cl = "inoculation"; $cllabel=$LANG{'history_label_spam'}; }
+    elsif ($class eq "C") { $cl = "corpus"; $cllabel=$LANG{'history_label_corpus'}; }
+    elsif ($class eq "U") { $cl = "unknown"; $cllabel=$LANG{'history_label_unknown'}; }
+    elsif ($class eq "E") { $cl = "error"; $cllabel=$LANG{'history_label_error'}; }
     if ($messageid ne "") {
       if ($rec{$messageid}->{'resend'} ne "") {
         $cl = "relay";
-        $cllabel = "Resend";
+        $cllabel = $LANG{'history_label_resend'};
       }
       $rec{$messageid}->{'resend'} = $signature;
     }
@@ -411,13 +416,13 @@ sub DisplayHistory {
 
     my($retrain);
     if ($rec{$signature}->{'class'} =~ /^(M|F)$/ && $rec{$signature}->{'count'} % 2 != 0) {
-      $retrain = "<b>Retrained</b>";
+      $retrain = "<b>$LANG{'history_retrained'}</b>";
     } 
 
     if ($retrain eq "") {
-      $retrain = qq!<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">As ! . ucfirst($rclass) . "</A>";
+      $retrain = qq!<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">$LANG{'history_retrain_as'} ! . ucfirst($LANG{"history_retrain_as_" . $rclass}) . "</A>";
     } else {
-      $retrain .= qq! (<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">Undo</A>)!;
+      $retrain .= qq! (<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">$LANG{'history_retrain_undo'}</A>)!;
     }
 
     my($path) = "$USER.frag/$signature.frag";
@@ -496,29 +501,29 @@ _END
   }
 
   $DATA{'SHOW'} = $show;
-  $DATA{'SHOW_SELECTOR'} .=  "Show: <a href=\"$MYURL&show=all\">";
+  $DATA{'SHOW_SELECTOR'} .=  "$LANG{'history_show'}: <a href=\"$MYURL&show=all\">";
   if ($show eq "all") {
-    $DATA{'SHOW_SELECTOR'} .= "<strong>all</strong>";
+    $DATA{'SHOW_SELECTOR'} .= "<strong>$LANG{'history_show_all'}</strong>";
   } else {
-    $DATA{'SHOW_SELECTOR'} .= "all";
+    $DATA{'SHOW_SELECTOR'} .= "$LANG{'history_show_all'}";
   }
   $DATA{'SHOW_SELECTOR'} .=  "</a> | <a href=\"$MYURL&show=spam\">";
   if ($show eq "spam") {
-    $DATA{'SHOW_SELECTOR'} .= "<strong>spam</strong>";
+    $DATA{'SHOW_SELECTOR'} .= "<strong>$LANG{'history_show_spam'}</strong>";
   } else {
-    $DATA{'SHOW_SELECTOR'} .= "spam";
+    $DATA{'SHOW_SELECTOR'} .= "$LANG{'history_show_spam'}";
   }
   $DATA{'SHOW_SELECTOR'} .=  "</a> | <a href=\"$MYURL&show=innocent\">";
   if ($show eq "innocent") {
-    $DATA{'SHOW_SELECTOR'} .= "<strong>innocent</strong>";
+    $DATA{'SHOW_SELECTOR'} .= "<strong>$LANG{'history_show_innocent'}</strong>";
   } else {
-    $DATA{'SHOW_SELECTOR'} .= "innocent";
+    $DATA{'SHOW_SELECTOR'} .= "$LANG{'history_show_innocent'}";
   }
   $DATA{'SHOW_SELECTOR'} .=  "</a> | <a href=\"$MYURL&show=whitelisted\">";
   if ($show eq "whitelisted") {
-    $DATA{'SHOW_SELECTOR'} .= "<strong>whitelisted</strong>";
+    $DATA{'SHOW_SELECTOR'} .= "<strong>$LANG{'history_show_whitelisted'}</strong>";
   } else {
-    $DATA{'SHOW_SELECTOR'} .= "whitelisted";
+    $DATA{'SHOW_SELECTOR'} .= "$LANG{'history_show_whitelisted'}";
   }
   $DATA{'SORT_SELECTOR'} .=  "</a>";
 
@@ -543,10 +548,10 @@ sub DisplayAnalysis {
   my ($dailystart) = time - (3600*23);
 
   if (! -e $LOG) {
-    &error("No historical data is available.");
+    &error($LANG{'error_no_historic'});
   }
 
-  open(LOG, "<$LOG") || &error("Unable to open logfile: $!");
+  open(LOG, "<$LOG") || &error("$LANG{'error_cannot_open_log'}: $!");
   while(<LOG>) {
     my($t_log, $c_log) = split(/\t/);
 
@@ -696,7 +701,7 @@ sub DisplayPreferences {
 
 
     } else {
-      open(FILE, ">$FILE") || do { &error("Unable to write preferences: $!"); };
+      open(FILE, ">$FILE") || do { &error("$LANG{'error_cannot_write_prefs'}: $!"); };
       print FILE <<_END;
 trainingMode=$FORM{'trainingMode'}
 spamAction=$FORM{'spamAction'}
@@ -742,9 +747,9 @@ _END
   }
 
   if ($CONFIG{'OPTMODE'} eq "OUT") {
-    $DATA{"OPTION"} = "<INPUT TYPE=CHECKBOX NAME=optOut " . $DATA{'C_OPTOUT'} . ">Disable DSPAM filtering<br>";
+    $DATA{"OPTION"} = "<INPUT TYPE=CHECKBOX NAME=optOut " . $DATA{'C_OPTOUT'} . ">$LANG{'option_disable_filtering'}<br>";
   } elsif ($CONFIG{'OPTMODE'} eq "IN") {
-    $DATA{"OPTION"} = "<INPUT TYPE=CHECKBOX NAME=optIn " . $DATA{'C_OPTIN'} . ">Enable DSPAM filtering<br>";
+    $DATA{"OPTION"} = "<INPUT TYPE=CHECKBOX NAME=optIn " . $DATA{'C_OPTIN'} . ">$LANG{'option_enable_filtering'}<br>";
   } else {
     $DATA{"OPTION"} = "";
   }
@@ -769,7 +774,7 @@ sub ProcessQuarantine {
 sub ProcessFalsePositive {
   my(@buffer, %head, $found);
   if ($FORM{'signatureID'} eq "") {
-    &error("No Message ID Specified");
+    &error($LANG{'error_no_sigid'});
   }
   open(FILE, "<$MAILBOX");
   while(<FILE>) {
@@ -907,7 +912,7 @@ sub Quarantine_ViewMessage {
   my(@buffer);
 
   if ($FORM{'signatureID'} eq "") {
-    &error("No Message ID Specified");
+    &error($LANG{'error_no_sigid'});
   }
 
   $DATA{'MESSAGE_ID'} = $FORM{'signatureID'};
@@ -1153,27 +1158,27 @@ sub DisplayQuarantine {
   $DATA{'SORTBY'} = $sortBy;
   $DATA{'SORT_QUARANTINE'} .=  "<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&template=quarantine&sortby=Rating&user=$FORM{'user'}\">";
   if ($sortBy eq "Rating") {
-    $DATA{'SORT_QUARANTINE'} .= "<strong>Rating</strong>";
+    $DATA{'SORT_QUARANTINE'} .= "<strong>$LANG{'quarantine_rating'}</strong>";
   } else {
-    $DATA{'SORT_QUARANTINE'} .= "Rating";
+    $DATA{'SORT_QUARANTINE'} .= $LANG{'quarantine_rating'};
   }
   $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&template=quarantine&sortby=Date&user=$FORM{'user'}\">";
   if ($sortBy eq "Date") {
-    $DATA{'SORT_QUARANTINE'} .= "<strong>Date</strong>";
+    $DATA{'SORT_QUARANTINE'} .= "<strong>$LANG{'quarantine_date'}</strong>";
   } else {
-    $DATA{'SORT_QUARANTINE'} .= "Date";
+    $DATA{'SORT_QUARANTINE'} .= $LANG{'quarantine_date'};
   }
   $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&template=quarantine&sortby=From&user=$FORM{'user'}\">";
   if ($sortBy eq "From") {
-    $DATA{'SORT_QUARANTINE'} .= "<strong>From</strong>";
+    $DATA{'SORT_QUARANTINE'} .= "<strong>$LANG{'quarantine_from'}</strong>";
   } else {
-    $DATA{'SORT_QUARANTINE'} .= "From";
+    $DATA{'SORT_QUARANTINE'} .= $LANG{'quarantine_from'};
   }
   $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&template=quarantine&sortby=Subject&user=$FORM{'user'}\">";
   if ($sortBy eq "Subject") {
-    $DATA{'SORT_QUARANTINE'} .= "<strong>Subject</strong>";
+    $DATA{'SORT_QUARANTINE'} .= "<strong>$LANG{'quarantine_subject'}</strong>";
   } else {
-    $DATA{'SORT_QUARANTINE'} .= "Subject";
+    $DATA{'SORT_QUARANTINE'} .= $LANG{'quarantine_subject'};
   }
   $DATA{'SORT_QUARANTINE'} .=  "</a></th>";
 
@@ -1410,7 +1415,7 @@ sub DisplayIndex {
 
 sub AddAlert {
   if ($FORM{'ALERT'} eq "") {
-    &error("No Alert Specified");
+    &error($LANG{'error_no_alert_specified'});
   }
   open(FILE, ">>$USER.alerts");
   print FILE "$FORM{'ALERT'}\n";
@@ -1422,7 +1427,7 @@ sub DeleteAlert {
   my($line, @alerts);
   $line = 0;
   if ($FORM{'line'} eq "") {
-    &Error("No Alert Specified");
+    &Error($LANG{'error_no_alert_specified'});
   }
   open(FILE, "<$USER.alerts");
   while(<FILE>) {
@@ -1445,7 +1450,7 @@ sub DisplayAlerts {
   $DATA{'ALERTS'} = <<_end;
 <table border="0" cellspacing="0" cellpadding="2">
 	<tr>
-		<th>Alert Name</th>
+		<th>$LANG{'alert_name'}</th>
 		<th>&nbsp;</th>
 	</tr>
 _end
@@ -1459,7 +1464,7 @@ _end
     while(<FILE>) {
       s/</&lt;/g;
       s/>/&gt;/g;
-      $DATA{'ALERTS'} .= qq!<tr><td class="$rowclass">$_</td><td class="$rowclass">[<a href="$CONFIG{'ME'}?command=deleteAlert&user=$FORM{'user'}&template=alerts&line=$line">Remove</a>]</td></tr>\n!;
+      $DATA{'ALERTS'} .= qq!<tr><td class="$rowclass">$_</td><td class="$rowclass">[<a href="$CONFIG{'ME'}?command=deleteAlert&user=$FORM{'user'}&template=alerts&line=$line">$LANG{'remove_alert'}</a>]</td></tr>\n!;
       $line++;
 
       if ($rowclass eq "rowEven") {
@@ -1505,11 +1510,11 @@ sub output {
   # Check admin permissions
   do {
     if ($CONFIG{'ADMIN'} == 1) {
-      $DATA{'NAV_ADMIN'} = qq!<li><a href="admin.cgi">Administrative Suite</a></li>!;
-      $DATA{'FORM_USER'} = qq!<form action="$CONFIG{'ME'}"><input type=hidden name="template" value="$FORM{'template'}">Statistical SPAM Protection for <INPUT TYPE=TEXT NAME=user SIZE=16 value="$CURRENT_USER"> <input type=submit value="Change"></form>!;
+      $DATA{'NAV_ADMIN'} = qq!<li><a href="admin.cgi">$LANG{'admin_suite'}</a></li>!;
+      $DATA{'FORM_USER'} = qq!<form action="$CONFIG{'ME'}"><input type=hidden name="template" value="$FORM{'template'}">$LANG{'user_form'} <INPUT TYPE=TEXT NAME=user SIZE=16 value="$CURRENT_USER"> <input type=submit value=$LANG{'user_f$
     } else {
       $DATA{'NAV_ADMIN'} = '';
-      $DATA{'FORM_USER'} = "Statistical SPAM Protection for <strong>$CURRENT_USER</strong>";
+      $DATA{'FORM_USER'} = "$LANG{'user_form'} <strong>$CURRENT_USER</strong>";
     }
   };
 
@@ -1544,10 +1549,11 @@ sub error {
   my($error) = @_;
   $FORM{'template'} = "error";
   $DATA{'MESSAGE'} = <<_end;
-The following error occured while trying to process your request: <BR>
+$LANG{'error_message_part1'}
+<BR>
 <B>$error</B><BR>
 <BR>
-If this problem persists, please contact your administrator.
+$LANG{'error_message_part2'}
 _end
   &output(%DATA);
   exit;
@@ -1589,7 +1595,7 @@ sub CheckQuarantine {
   }
   close(FILE);   
   if ($f == 0) {
-    $f = "Empty";
+    $f = $LANG{'empty'};
   }
 
   $DATA{'TOTAL_QUARANTINED_MESSAGES'} = $f;
@@ -1657,7 +1663,7 @@ sub GetPrefs {
   if (keys(%PREFS) eq "0" || $CONFIG{'PREFERENCES_EXTENSION'} != 1) {
 
     if (! -e "./default.prefs") {
-      &error("Unable to load default preferences");
+      &error($LANG{'error_load_default_prefs'});
     }
     open(FILE, "<./default.prefs");
     while(<FILE>) {
diff --git a/webui/cgi-bin/graph.cgi b/webui/cgi-bin/graph.cgi
index ba6b27d..9987d75 100755
--- a/webui/cgi-bin/graph.cgi
+++ b/webui/cgi-bin/graph.cgi
@@ -22,10 +22,15 @@ use CGI ':standard';
 use GD::Graph::lines3d;
 use GD::Graph::lines;
 use strict;
-use vars qw { %CONFIG %FORM @spam_day @nonspam_day @period @data };
+use vars qw { %CONFIG %FORM %LANG @spam_day @nonspam_day @period @data };
 
 # Read configuration parameters common to all CGI scripts
 require "configure.pl";
+if (-s "$CONFIG{'TEMPLATES'}/strings.txt") {
+        require "$CONFIG{'TEMPLATES'}/strings.txt";
+} else {
+        require "$CONFIG{'TEMPLATES'}/../strings.txt";
+} 
 
 %FORM = &ReadParse();
 
@@ -47,7 +52,7 @@ if ($CONFIG{'3D_GRAPHS'} == 1) {
 }
 $mygraph->set(
     x_label     => "$FORM{'x_label'}",
-    y_label     => 'Number of Messages',
+    y_label     => $LANG{'graph_legend_nb_messages'},
 #   title       => "$FORM{'title'}",
     line_width   => 2,
     dclrs => [ qw(lred dgreen) ],
@@ -64,7 +69,7 @@ $mygraph->set(
 #         dclrs => [ qw( darkorchid2 mediumvioletred deeppink darkturquoise ) ],
 
 $mygraph->set_legend_font(GD::gdMediumBoldFont);
-$mygraph->set_legend('SPAM', 'Good');
+$mygraph->set_legend(" $LANG{'graph_legend_spam'}", " $LANG{'graph_legend_good'}");
 my $myimage = $mygraph->plot(\...@data) or die $mygraph->error;
                                                                                 
 print "Content-type: image/png\n\n";
diff --git a/webui/cgi-bin/templates/strings.txt b/webui/cgi-bin/templates/strings.txt
new file mode 100644
index 0000000..6866201
--- /dev/null
+++ b/webui/cgi-bin/templates/strings.txt
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+$LANG{'empty'}                          = "Empty";
+$LANG{'admin_suite'}                    = "Administrative Suite";
+$LANG{'alert_name'}                     = "Alert Name";
+$LANG{'remove_alert'}                   = "Remove";
+$LANG{'user_form'}                      = "Statistical SPAM Protection for";
+$LANG{'user_form_submit'}               = "Change";
+
+$LANG{'option_disable_filtering'}       = "Disable DSPAM filtering";
+$LANG{'option_enable_filtering'}        = "Enable DSPAM filtering";
+
+$LANG{'quarantine_rating'}              = "Rating";
+$LANG{'quarantine_date'}                = "Date";
+$LANG{'quarantine_from'}                = "From";
+$LANG{'quarantine_subject'}             = "Subject";
+
+$LANG{'history_show'}                   = "Show";
+$LANG{'history_show_all'}               = "all";
+$LANG{'history_show_spam'}              = "spam";
+$LANG{'history_show_innocent'}          = "innocent";
+$LANG{'history_show_whitelisted'}       = "whitelisted";
+$LANG{'history_retrain_as_spam'}        = "spam";
+$LANG{'history_retrain_as_innocent'}    = "innocent";
+$LANG{'history_retrain_as'}             = "As ";
+$LANG{'history_retrain_undo'}           = "Undo";
+$LANG{'history_retrained'}              = "Retrained";
+$LANG{'history_label_resend'}           = "Resend";
+$LANG{'history_label_whitelist'}        = "Whitelist";
+$LANG{'history_label_spam'}             = "SPAM";
+$LANG{'history_label_innocent'}         = "Good";
+$LANG{'history_label_miss'}             = "Miss";
+$LANG{'history_label_virus'}            = "Virus";
+$LANG{'history_label_RBL'}              = "RBL";
+$LANG{'history_label_block'}            = "BLOCK";
+$LANG{'history_label_corpus'}           = "Corpus";
+$LANG{'history_label_unknown'}          = "UNKN";
+$LANG{'history_label_error'}            = "Error";
+
+$LANG{'error_no_historic'}              = "No historical data is available.";
+$LANG{'error_cannot_open_log'}          = "Unable to open logfile";
+$LANG{'error_no_identity'}              = "System Error. I was unable to determine your identity.";
+$LANG{'error_invalid_command'}          = "Invalid Command";
+$LANG{'error_cannot_write_prefs'}       = "Unable to write preferences";
+$LANG{'error_no_sigid'}                 = "No Message ID Specified";
+$LANG{'error_no_alert_specified'}       = "No Alert Specified.";
+$LANG{'error_message_part1'}            = "The following error occured while trying to process your request:";
+$LANG{'error_message_part2'}            = "If this problem persists, please contact your administrator.";
+$LANG{'error_filesystem_scale'}         = "Unable to determine filesystem scale";
+$LANG{'error_load_default_prefs'}       = "Unable to load default preferences";
+$LANG{'error_access_denied'}            = "Access Denied";
+
+$LANG{'graph_legend_nb_messages'}       = "Number of Messages";
+$LANG{'graph_legend_spam'}              = "SPAM";
+$LANG{'graph_legend_good'}              = "Good";
+$LANG{'graph_legend_inoculations'}      = "Inoculations";
+$LANG{'graph_legend_corpusfeds'}        = "Corpusfeds";
+$LANG{'graph_legend_virus'}             = "Virus";
+$LANG{'graph_legend_RBL'}               = "Blacklisted (RBL)";
+$LANG{'graph_legend_blocklisted'}       = "Blocklisted";
+$LANG{'graph_legend_whitelisted'}       = "Auto-Whitelisted";
+$LANG{'graph_legend_nonspam'}           = "Nonspam";
+$LANG{'graph_legend_spam_misses'}       = "Spam Misses";
+$LANG{'graph_legend_falsepositives'}    = "False Positives";
+
+1;
+
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Dspam-devel mailing list
Dspam-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspam-devel

Reply via email to