1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | ###########################################################################
|
---|
4 | #
|
---|
5 | # translator.pl
|
---|
6 | #
|
---|
7 | # A component of the Greenstone digital library software
|
---|
8 | # from the New Zealand Digital Library Project at the
|
---|
9 | # University of Waikato, New Zealand.
|
---|
10 | #
|
---|
11 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or modify
|
---|
14 | # it under the terms of the GNU General Public License as published by
|
---|
15 | # the Free Software Foundation; either version 2 of the License, or
|
---|
16 | # (at your option) any later version.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful,
|
---|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
21 | # GNU General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, write to the Free Software
|
---|
25 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
26 | #
|
---|
27 | ###########################################################################
|
---|
28 |
|
---|
29 |
|
---|
30 | BEGIN {
|
---|
31 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
32 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
33 | }
|
---|
34 |
|
---|
35 | use parsargv;
|
---|
36 | use util;
|
---|
37 | use Cwd;
|
---|
38 | use File::Basename;
|
---|
39 | use GDBM_File;
|
---|
40 | use CGI;
|
---|
41 |
|
---|
42 |
|
---|
43 | sub main
|
---|
44 | {
|
---|
45 | my $query = new CGI;
|
---|
46 | my @languages;
|
---|
47 |
|
---|
48 | # directory in which to put the generated html pages
|
---|
49 | my $dir = "$ENV{'GSDLHOME'}/tmp/lang/package_forms";
|
---|
50 | # creates directory if it doesn't already exist
|
---|
51 | if (!-e $dir) {
|
---|
52 | my $store_umask = umask(0000);
|
---|
53 | if (! mkdir($dir, 0777)) {
|
---|
54 | umask($store_umask);
|
---|
55 | die "Couldn't create directory $dir\n";
|
---|
56 | }
|
---|
57 | umask($store_umask);
|
---|
58 | }
|
---|
59 |
|
---|
60 | open(LANGFILE, "<$dir/languages.log") or die "MURGH\n";
|
---|
61 |
|
---|
62 | while (<LANGFILE>) {
|
---|
63 | $lang = $_;
|
---|
64 | chomp($lang);
|
---|
65 | push(@languages,$lang);
|
---|
66 | <LANGFILE>;
|
---|
67 | }
|
---|
68 |
|
---|
69 | close LANGFILE;
|
---|
70 |
|
---|
71 | open(HTMLFILE, ">$dir/picklanguage.lang") or die "MURGH\n";
|
---|
72 |
|
---|
73 | print HTMLFILE ("<center><strong><br>\n",
|
---|
74 | "Welcome to the Greenstone Language Translation Facility</strong><p>\n",
|
---|
75 | "<table border=\"2\" cellpadding=\"8\"><tr><td><center>",
|
---|
76 | "Please select a base language from which to translate: <p>\n",
|
---|
77 | $query->popup_menu(-name=>"baselanguage",
|
---|
78 | -values=>\@languages,
|
---|
79 | -default=>'english'),
|
---|
80 | "<p></center></td><td><center>\n",
|
---|
81 | "Please select the language you are translating into: <p>\n",
|
---|
82 | $query->popup_menu(-name=>"language",
|
---|
83 | -values=>\@languages),
|
---|
84 | "<p>\n",
|
---|
85 | "Or enter the name of a new language: <p>\n",
|
---|
86 | $query->textfield(-name=>"ownchoice",
|
---|
87 | -default=>"",
|
---|
88 | -size=>50),
|
---|
89 | "<p></center></td></tr></table>\n",
|
---|
90 | $query->submit("submitlanguage","CONTINUE >>"),
|
---|
91 | "</center><br>\n");
|
---|
92 |
|
---|
93 | close HTMLFILE;
|
---|
94 | }
|
---|
95 |
|
---|
96 | &main();
|
---|