[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm lonspreadsheet.pm

www lon-capa-cvs@mail.lon-capa.org
Sat, 11 Oct 2003 14:04:54 -0000


This is a MIME encoded message

--www1065881094
Content-Type: text/plain

www		Sat Oct 11 10:04:54 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm lonspreadsheet.pm 
  Log:
  Internationalize and fix "seperate".
  
  
--www1065881094
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20031011100454.txt"

Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.27 loncom/interface/spreadsheet/Spreadsheet.pm:1.28
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.27	Tue Sep 16 11:36:32 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Sat Oct 11 10:04:54 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.27 2003/09/16 15:36:32 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.28 2003/10/11 14:04:54 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,6 +59,7 @@
 use HTML::TokeParser;
 use Spreadsheet::WriteExcel;
 use Time::HiRes;
+use Apache::lonlocal;
 
 ##
 ## Package Variables
@@ -1282,7 +1283,7 @@
     my $self = shift;
     return '' if (! $ENV{'request.role.adv'});
     return "<table>\n".
-        '<tr><th align="center">Output Format</th><tr>'."\n".
+        '<tr><th align="center">'.&mt('Output Format').'</th><tr>'."\n".
         '<tr><td>'.&output_selector()."</td></tr>\n".
         "</table>\n";
 }
@@ -1297,13 +1298,13 @@
     }
     foreach (['html','HTML'],
              ['excel','Excel'],
-             ['csv','Comma Seperated Values']) {
+             ['csv','Comma Separated Values']) {
         my ($name,$description) = @{$_};
         $output_selector.=qq{<option value="$name"};
         if ($name eq $default) {
             $output_selector .= ' selected';
         }
-        $output_selector .= ">$description</option>\n";
+        $output_selector .= ">".&mt($description)."</option>\n";
     }
     $output_selector .= "</select>\n";
     return $output_selector;
@@ -1336,9 +1337,9 @@
     my $workbook  = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
     if (! defined($workbook)) {
         $r->log_error("Error creating excel spreadsheet $filename: $!");
-        $r->print("Problems creating new Excel file.  ".
+        $r->print(&mt("Problems creating new Excel file.  ".
                   "This error has been logged.  ".
-                  "Please alert your LON-CAPA administrator");
+                  "Please alert your LON-CAPA administrator"));
         return undef;
     }
     #
@@ -1356,7 +1357,7 @@
     my $self = shift;
     my ($r) = @_;
     my $connection = $r->connection();
-    $r->print("<h2>Preparing Excel Spreadsheet</h2>");
+    $r->print("<h2>".&mt('Preparing Excel Spreadsheet')."</h2>");
     #
     # Create excel worksheet
     my ($workbook,$filename) = $self->create_excel_spreadsheet($r);
@@ -1408,9 +1409,9 @@
     my $file;
     unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) {
         $r->log_error("Couldn't open $filename for output $!");
-        $r->print("Problems occured in writing the csv file.  ".
+        $r->print(&mt("Problems occured in writing the csv file.  ".
                   "This error has been logged.  ".
-                  "Please alert your LON-CAPA administrator.");
+                  "Please alert your LON-CAPA administrator."));
         $r->print("<pre>\n".$csvdata."</pre>\n");
         return 0;
     }
@@ -1426,7 +1427,7 @@
     # Close the csv file
     close($file);
     $r->print('<br /><br />'.
-              '<a href="'.$filename.'">Your CSV spreadsheet.</a>'."\n");
+              '<a href="'.$filename.'">'.&mt('Your CSV spreadsheet.').'</a>'."\n");
     #
     return 1;
 }
@@ -1752,9 +1753,9 @@
                                       $self->{'cdom'}, $self->{'cnum'});
     my ($tmp) = keys(%results);
     if ($tmp =~ /^(con_lost|error|no_such_host)/i ) {
-        @alternatives = ('Default');
+        @alternatives = (&mt('Default'));
     } else {
-        @alternatives = ('Default', sort (keys(%results)));
+        @alternatives = (&mt('Default'), sort (keys(%results)));
     }
     return @alternatives; 
 }
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.26 loncom/interface/spreadsheet/lonspreadsheet.pm:1.27
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.26	Tue Sep 30 11:40:09 2003
+++ loncom/interface/spreadsheet/lonspreadsheet.pm	Sat Oct 11 10:04:54 2003
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.26 2003/09/30 15:40:09 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.27 2003/10/11 14:04:54 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -87,7 +87,7 @@
     foreach (sort keys(%options)) {
         $selout.='<option value="'.$_.'"';
         if ($_ eq $value) { $selout.=' selected'; }
-        $selout.='>'.$options{$_}.'</option>';
+        $selout.='>'.&mt($options{$_}).'</option>';
     }
     return $selout.'</select>';
 }
@@ -122,10 +122,10 @@
         $result .=&hiddenfield('workcopy',$sheettype);
         if ($ENV{'form.newformula'} !~ /^\s*$/) {
             $message .='<table><tr>'.
-              '<td valign="top"><pre>Cell '.$ENV{'form.cell'}.' = </pre></td>'.
+              '<td valign="top"><pre>'.&mt('Cell').' '.$ENV{'form.cell'}.' = </pre></td>'.
               '<td><pre>'.$ENV{'form.newformula'}."</pre></td></tr></table>\n";
         } else {
-            $message .= 'Deleted contents of cell '.$ENV{'form.cell'}.'.';
+            $message .= &mt('Deleted contents of cell').' '.$ENV{'form.cell'}.'.';
         }
     }
     ##
@@ -140,18 +140,19 @@
         $filename = 'Default';
     }
     my $save_dialog = '<nobr>'.
-        '<input type="submit" name="save" value="Save as" /> '.
+        '<input type="submit" name="save" value="'.&mt('Save as').'" /> '.
         '<input type="text" name="savefilename" size="30" value="'.
         $truefilename.'" />'.
         '</nobr>';
     my $makedefault_dialog = '<input type="submit" name="makedefault" '.
-        'value="Save as & Make This Sheet the Default"/>';
+        'value="'.&mt('Save as & Make This Sheet the Default').'"/>';
     #
     my $link = '<a href="javascript:openbrowser'.
-        "('sheet','loadfilename','spreadsheet')\">Select Spreadsheet File</a>";
+        "('sheet','loadfilename','spreadsheet')\">".&mt('Select Spreadsheet File')."</a>";
+    my $load=&mt('Load:');
     my $load_dialog = <<END;
 <table bgcolor="$bgcolor">
-<tr><td><input type="submit" name="load" value="Load" /></td>
+<tr><td><input type="submit" name="load" value="$load" /></td>
     <td><nobr>
         <input type="text" name="loadfilename" size="20" value="$filename" />
         $link</nobr>
@@ -312,6 +313,11 @@
     ## Spit out the javascript required for editing
     ##
     if ($allowed_to_edit) {
+	my %lt=(
+		'ce' => 'Cell',
+		'ac' => 'Accept',
+		'dc' => 'Discard Changes'
+	);
         my $extra_javascript = 
             &Apache::loncommon::browser_and_searcher_javascript();
         $r->print(<<ENDSCRIPT);
@@ -327,11 +333,11 @@
         // we need to escape them?  
         edit_text +='<html><head><title>Cell Edit Window</title></head><body>';
         edit_text += '<form name="editwinform">';
-        edit_text += '<center><h3>Cell '+cellname+'</h3>';
+        edit_text += '<center><h3>$lt{'ce'} '+cellname+'</h3>';
         edit_text += '<textarea name="newformula" cols="60" rows="12"';
         edit_text += ' wrap="off" >'+cellformula+'</textarea>';
         edit_text += '</br>';
-        edit_text += '<input type="button" name="accept" value="Accept"';
+        edit_text += '<input type="button" name="accept" value="$lt{'ac'}"';
         edit_text += ' onClick=\\\'javascript:';
         edit_text += 'opener.document.sheet.cell.value=';
         edit_text +=     '"'+cellname+'";';
@@ -341,7 +347,7 @@
         edit_text += 'self.close()\\\' />';
         edit_text += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         edit_text += '<input type="button" name="abort" ';
-        edit_text +=     'value="Discard Changes"';
+        edit_text +=     'value="$lt{'dc'}"';
         edit_text += ' onClick="javascript:self.close()" />';
         edit_text += '</center></body></html>';
 
@@ -430,13 +436,13 @@
             if ($action_message) {
                 $action_message .= '<br />';
             }
-            $action_message .= 'Made this spreadsheet the default';
+            $action_message .= &mt('Made this spreadsheet the default');
             if ($sheettype eq 'classcalc') {
-                $action_message .= ' for the course';
+                $action_message .= ' '.&mt('for the course');
             } elsif ($sheettype eq 'studentcalc') {
-                $action_message .= ' for all students';
+                $action_message .= ' '.&mt('for all students');
             } elsif ($sheettype eq 'assesscalc') {
-                $action_message .= ' for all assessments';
+                $action_message .= ' '.&mt('for all assessments');
             }
             $action_message .= '.';
         }

--www1065881094--