File:  [LON-CAPA] / loncom / cgi / translator.pl
Revision 1.1: download - view: text, annotated - select for diffs
Tue Sep 16 22:40:25 2003 UTC (20 years, 7 months ago) by www
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
Continued work on Maketext
* can now set language preferences
* adv users can set "translator" language, and access little script to
enter translations for phrases covered by &mt

    1: #!/usr/bin/perl
    2: $|=1;
    3: # Generates a html page showing various sataus reports about the cluster
    4: # $Id: translator.pl,v 1.1 2003/09/16 22:40:25 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: use strict;
   29: use GDBM_File;
   30: 
   31: my $buffer;
   32: 
   33: read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   34: my @pairs=split(/&/,$buffer);
   35: my $pair; my $name; my $value;
   36: 
   37: my %FORM=();
   38: my %hash=();
   39: 
   40: foreach $pair (@pairs) {
   41:     ($name,$value) = split(/=/,$pair);
   42:     $value =~ tr/+/ /;
   43:     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   44:     $FORM{$name}=$value;
   45: } 
   46: 
   47: 
   48: $buffer=$ENV{'QUERY_STRING'};
   49: @pairs=split(/&/,$buffer);
   50: foreach $pair (@pairs) {
   51:     ($name,$value) = split(/=/,$pair);
   52:     $value =~ tr/+/ /;
   53:     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   54:     $FORM{$name}=$value;
   55: } 
   56: print 'Content-type: text/html'."\n\n";
   57: 
   58: 
   59:     print (<<ENDSCREEN);
   60: <html><body>
   61: <h1>LON-CAPA Localization Project</h1>
   62: <h3>Language: $FORM{'lang'}</h3>
   63: <a href="/cgi-bin/translator.pl?lang=$FORM{'lang'}&list=1">List all</a><br />
   64: ENDSCREEN
   65: 
   66: $FORM{'lang'}=~s/\W//g;
   67: 
   68: if ($FORM{'trans'}) {
   69:     if (tie(%hash,'GDBM_File',
   70: 	  '/home/httpd/perl/logs/'.$FORM{'lang'}.'.db',&GDBM_WRCREAT(),0640)) {
   71: 	$hash{$FORM{'arg1'}}=$FORM{'trans'};
   72: 	untie %hash;
   73: 	print "Stored.";
   74:     }
   75: } elsif ($FORM{'list'}) {
   76:     if (tie(%hash,'GDBM_File',
   77: 	  '/home/httpd/perl/logs/'.$FORM{'lang'}.'.db',&GDBM_READER(),0640)) {
   78: 	print "<pre>";
   79: 	foreach (sort keys %hash) {
   80: 	    print "\n   '".$_."'".
   81: 		"\n=> '".$hash{$_}."',\n";
   82: 	}
   83: 	print "</pre>";
   84: 	untie %hash;
   85:     }
   86: } else {
   87:     my $trans=$FORM{'arg1'};
   88:     if (tie(%hash,'GDBM_File',
   89: 	  '/home/httpd/perl/logs/'.$FORM{'lang'}.'.db',&GDBM_READER(),0640)) {
   90: 	if ($hash{$trans}) { $trans=$hash{$trans}; }
   91: 	untie %hash;
   92:     }
   93:     print (<<ENDQUERY);
   94: <blockquote>$FORM{'arg1'}</blockquote>
   95: <form method="post">
   96: <input type="hidden" name="org" value="$FORM{'arg1'}">
   97: <input type="hidden" name="lang" value="$FORM{'lang'}">
   98: <input type="text" size="80" name="trans" value="$trans">
   99: <input type="submit">
  100: </form>
  101: ENDQUERY
  102: }
  103: 
  104: print('</body></html>');
  105: exit 0;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>