#!/usr/bin/perl
#
# $Id: Interpreter.pl,v 1.8 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: Interpreter.pl
# Get config
require 'sitecfg.pl';
require 'testlib.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
$FORM{'submit'} =~ s/\+/ /g;
if ($FORM{'submit'} eq 'Save Changes') {
$sNotice = "Translations updated";
&UpdateTranslation();
} elsif ($FORM{'submit'} eq 'printtable') {
&PrintPrintForm();
} elsif ($FORM{'submit'} eq 'printenglish') {
&PrintEnglishForm();
} else {
$sNotice = "";
&PrintForm();
}
}
sub PrintForm {
$nshref = ($SESSION{'browserapp'} eq MSIE) ? "" : "HREF=\"#top\"";
if ($SESSION{'uac'} =~ /txlatr./ ) {
$sPrintlink="";
$logoutbutton = "
\n\n";
$logoutjscript = "
function log_out(objForm) {
var sURL;
sURL = \"$PATHS{'cgiroot'}/logout.pl?tid=$SESSION{'tid'}&idle=N\";
top.document.location.replace(sURL);
}\n";
} else {
$logoutbutton = "";
$logoutjscript = "";
$sPrintlink="Print-Translations
Print-English";
}
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$idTranslation = $FORM{'lang'};
@sTranslation = &get_phrases($idTranslation);
$txtTranslation = $LANGUAGE_ID{$idTranslation};
$basefont="";
$fontface="";
$fontend = "";
if ($FORM{'lang'} eq 'arb') { $charset="iso-8859-6";}
elsif ($FORM{'lang'} eq 'cyr') {
$charset="iso-8859-5";
# $charset="koi8-r";
$basefont="";
$fontface="";
$fontend = "";
} else { $charset="iso-8859-1";}
$locator = "\n";
$locator = join('', $locator, "\[-\]\ \; ");
$locator = join('', $locator, "\[A\]\ \; ");
$locator = join('', $locator, "\[B\]\ \; ");
$locator = join('', $locator, "\[C\]\ \; ");
$locator = join('', $locator, "\[D\]\ \; ");
$locator = join('', $locator, "\[E\]\ \; ");
$locator = join('', $locator, "\[F\]\ \; ");
$locator = join('', $locator, "\[G\]\ \; ");
$locator = join('', $locator, "\[H\]\ \; ");
$locator = join('', $locator, "\[I\]\ \; ");
$locator = join('', $locator, "\[JL\]\ \; ");
$locator = join('', $locator, "\[M\]\ \; ");
$locator = join('', $locator, "\[N\]\ \; ");
$locator = join('', $locator, "\[O\]\ \; ");
$locator = join('', $locator, "\[P\]\ \; ");
$locator = join('', $locator, "\[Q\]\ \; ");
$locator = join('', $locator, "\[R\]\ \; ");
$locator = join('', $locator, "\[S\]\ \; ");
$locator = join('', $locator, "\[T\]\ \; ");
$locator = join('', $locator, "\[U\]\ \; ");
$locator = join('', $locator, "\[V\]\ \; ");
$locator = join('', $locator, "\[W\]\ \; ");
$locator = join('', $locator, "\[Y\]\ \; ");
$locator = join('', $locator, "\[+\]\ \;
\n");
$locator = join('', $locator, "\n");
$pad = "000";
for (0 .. $#sEnglish) {
$x = "$_";
$y = int(4 - length($x));
if ($y) {$x = join('', substr($pad,0,$y), $x);}
$locator = join('', $locator, "\[$x\]\ \; ");
}
print "
Test-Central $txtEnglish-$txtTranslation Translation
$basefont
";
}
sub UpdateTranslation {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
@sTranslation = &get_phrases($FORM{'lang'});
$txtTranslation = $language;
$idTranslation = $languageid;
for (0 .. $#sEnglish) {
chop ($sTranslation[$_]);
$id = "x$_";
if ($FORM{$id} ne '') {
$sTranslation[$_] = $FORM{$id};
$sTranslation[$_] =~ s/\+/ /g;
if ($FORM{'lang'} ne 'kor') { $sTranslation[$_] =~ s/\&/\&\;/g; }
$sTranslation[$_] =~ s/\r//g;
$sTranslation[$_] =~ s/\n/
/g;
} else {
if ($sTranslation[$_] ne '') {
if ($FORM{'lang'} ne 'kor') { $sTranslation[$_] =~ s/\&/\&\;/g; }
$sTranslation[$_] =~ s/\r//g;
$sTranslation[$_] =~ s/\n/
/g;
} else {
$sTranslation[$_] = "$FORM{'lang'}-$_";
}
}
}
&put_phrases($FORM{'lang'});
&PrintForm();
}
sub PrintPrintForm {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$idTranslation = $FORM{'lang'};
@sTranslation = &get_phrases($idTranslation);
$txtTranslation = $LANGUAGE_ID{$idTranslation};
$basefont="";
$fontface="";
$fontend = "";
if ($FORM{'lang'} eq 'arb') { $charset="iso-8859-6";}
elsif ($FORM{'lang'} eq 'cyr') {
$charset="iso-8859-5";
# $charset="koi8-r";
$basefont="";
$fontface="";
$fontend = "";
} else { $charset="iso-8859-1";}
print "
Test-Central $txtEnglish-$txtTranslation Translation
$basefont
";
}
sub PrintEnglishForm {
$idEnglish = "enu";
@sEnglish = &get_phrases($idEnglish);
$txtEnglish = $LANGUAGE_ID{$idEnglish};
$fontface="";
$fontend = "";
$charset="iso-8859-1";
print "
Test-Central $txtEnglish Phrases
";
}