Changeset 4125
- Timestamp:
- 2003-04-11T10:20:42+12:00 (21 years ago)
- Location:
- trunk/gsdl/bin/script
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/picklanguage.pl
r4118 r4125 43 43 sub main 44 44 { 45 # directory in which to put the generated html pages 46 my $lang_dir = util::filename_cat($ENV{'GSDLHOME'},"tmp","lang"); 47 my @lang_list; 48 my $langlog_fname = util::filename_cat($lang_dir,"languages.log"); 45 my $gsdldir = "$ENV{'GSDLHOME'}"; 49 46 50 if (!-e $langlog_fname) {51 # generate one based on content of etc/main.cfg 52 my $maincfg_fname = util::filename_cat($ENV{'GSDLHOME'},"etc","main.cfg");47 # Read the languages available from etc/main.cfg 48 my $maincfg_fname = util::filename_cat($gsdldir, "etc", "main.cfg"); 49 open(MCFILE, "<$maincfg_fname") or die "Error: Could not open $maincfg_fname: $!\n"; 53 50 54 open(MCFILE, "<$maincfg_fname") 55 || die "Unable to open $maincfg_fname: $!\n"; 56 my $line; 57 while (defined ($line=<MCFILE>)) { 58 chomp($line); 59 if ($line =~ m/^Language\s+/i) { 60 my @args = split(/ +/,$line); 61 my ($lang_abbr) = ($args[1] =~ m/^shortname=(.*)$/); 62 my ($lang_long) = ($args[2] =~ m/^longname=(.*)$/); 63 push(@lang_list, { 'long' => $lang_long, 'abbr' => $lang_abbr } ); 64 } 51 my @languages; 52 my $line; 53 while (defined ($line=<MCFILE>)) { 54 chomp($line); 55 if ($line =~ m/^Language\s+/i) { 56 my @args = split(/ +/,$line); 57 my ($lang_abbr) = ($args[1] =~ m/^shortname=(.*)$/); 58 my ($lang_long) = ($args[2] =~ m/^longname=(.*)$/); 59 push(@languages, $lang_long); 65 60 } 66 close MCFILE; 61 } 62 close MCFILE; 67 63 68 open(LANGFILE,">$langlog_fname") 69 || die "Unable to create $langlog_fname: $!\n";64 # Write the HTML content of the page to tmp/lang/picklanguage.lang 65 my $picklang_fname = util::filename_cat($gsdldir, "tmp", "lang", "picklanguage.lang"); 70 66 71 my $l; 72 my $first = 1; 73 foreach $l ( @lang_list ) { 74 my $long = lc($l->{'long'}); 75 my $abbr = $l->{'abbr'}; 76 if ($first =~ 1) { 77 print LANGFILE "$long\n$abbr"; 78 $first = 0; 79 } 80 else { 81 print LANGFILE "\n$long\n$abbr"; 82 } 83 } 84 close LANGFILE; 67 # Make the file world writeable 68 my $currentmask = umask; 69 umask(0000); 70 if (! open(HTMLFILE,">$picklang_fname")) { 71 umask($currentmask); 72 die "Error: Could not create $picklang_fname: $!\n"; 85 73 } 74 umask($currentmask); 86 75 87 open(LANGFILE, "<$langlog_fname") 88 || die "Unable to open $langlog_fname for reading: $!\n"; 89 90 #reads into the languages array all languages currently in use 91 #and their corresponding language codes from the languages.log file 92 my @languages; 93 while (<LANGFILE>) { 94 $lang = $_; 95 chomp($lang); 96 push(@languages,$lang); 97 <LANGFILE>; 98 } 99 close LANGFILE; 100 101 #opens a file to write HTML content of the page to 102 my $picklang_fname = util::filename_cat($lang_dir, "picklanguage.lang"); 103 open(HTMLFILE, ">$picklang_fname") 104 || die "Unable to open $picklang_fname: $!\n"; 105 106 #writes to file the instructions on how to use the interface (_textinitial) 107 #and then displays a table at the end with menu options from which the user 108 #selects their base and translation languages, and submits these choices 109 #to proceed into the interface translation agency 76 # Writes to file the instructions on how to use the interface (_textinitial_) 77 # and then displays a table at the end with menu options from which the user 78 # selects their base and translation languages, and submits these choices 79 # to proceed into the interface translation agency 110 80 my $query = new CGI; 111 81 print HTMLFILE (" _textinitial_ <br>\n", … … 114 84 $query->popup_menu(-name=>"bl", 115 85 -values=>\@languages, 116 -default=>' english'),86 -default=>'English'), 117 87 "<p></center></td><td><center>\n", 118 88 "_textselectforeign_ <p>\n", … … 128 98 "</center><p>\n", 129 99 "<center><img src=\"_httpimg_/divb.gif\"></center><p>"); 130 131 100 close HTMLFILE; 132 101 } -
trunk/gsdl/bin/script/submit_translation.pl
r4118 r4125 68 68 $sourcelang =~ tr/A-Z/a-z/; 69 69 $targetlang =~ tr/A-Z/a-z/; 70 71 # Handles cases where the macro file name is different to the language name72 $sourcelang = "port" if ($sourcelang =~ m/portuguese/);73 $sourcelang = "indo" if ($sourcelang =~ m/indonesian/);74 $targetlang = "port" if ($targetlang =~ m/portuguese/);75 $targetlang = "indo" if ($targetlang =~ m/indonesian/);76 70 77 71 my $gsdldir = "$ENV{'GSDLHOME'}/"; … … 186 180 $macrotext = "[l=$targetcode] {" . $macrotext . "}\n"; 187 181 188 my $targetkey = &get_ target_key_equivalent($sourcelang, $targetlang, $sourcekey);182 my $targetkey = &get_macroname_equivalent($sourcelang, $targetlang, $sourcekey); 189 183 $translations{$targetkey} = $macrotext; 190 184 } … … 194 188 195 189 196 sub get_target_key_equivalent 197 { 198 my ($sourcelang, $targetlang, $sourcekey) = @_; 199 200 my $macrofile = $sourcekey; 190 sub get_macrofile_name 191 { 192 my ($language, $suffix) = @_; 193 194 my $macrofilename = $language; 195 196 # Handles cases where the macro file name is different to the language name 197 $macrofilename = "port" if ($language =~ m/portuguese/); 198 $macrofilename = "indo" if ($language =~ m/indonesian/); 199 200 # Add suffix (if any) and file extension, and return 201 $macrofilename = $macrofilename . $suffix . ".dm"; 202 return $macrofilename; 203 } 204 205 206 sub get_macroname_equivalent 207 { 208 my ($languageA, $languageB, $languageAkey) = @_; 209 210 my $macrofile = $languageAkey; 201 211 $macrofile =~ s/^([^:]+)::(.*)/$1/; 202 my $key = $ sourcekey;212 my $key = $languageAkey; 203 213 $key =~ s/^([^:])+::(.*)/$2/; 204 214 205 my $ targetkey;206 if ($macrofile eq ($sourcelang . ".dm")) {207 $ targetkey = $targetlang . ".dm". "::" . $key;208 } 209 if ($macrofile eq ($sourcelang . "2.dm")) {210 $ targetkey = $targetlang . "2.dm". "::" . $key;211 } 212 213 return ($ targetkey);215 my $languageBkey; 216 if ($macrofile eq &get_macrofile_name($languageA, "")) { 217 $languageBkey = &get_macrofile_name($languageB, "") . "::" . $key; 218 } 219 if ($macrofile eq &get_macrofile_name($languageA, "2")) { 220 $languageBkey = &get_macrofile_name($languageB, "2") . "::" . $key; 221 } 222 223 return ($languageBkey); 214 224 } 215 225 … … 246 256 my ($sourcelang, $targetlang, $macrosdir) = @_; 247 257 248 my $targetdmfile1 = $macrosdir . $targetlang . ".dm";249 my $targetdmfile2 = $macrosdir . $targetlang . "2.dm";258 my $targetdmfile1 = $macrosdir . &get_macrofile_name($targetlang, ""); 259 my $targetdmfile2 = $macrosdir . &get_macrofile_name($targetlang, "2"); 250 260 251 261 my $currentfile = "1"; … … 262 272 263 273 # Check if this is a target macro 264 if ($macrofile eq ($targetlang . ".dm") || $macrofile eq ($targetlang . "2.dm")) { 265 if ($macrofile eq ($targetlang . "2.dm") && $currentfile eq "1") { 274 if ($macrofile eq &get_macrofile_name($targetlang, "") || 275 $macrofile eq &get_macrofile_name($targetlang, "2")) { 276 277 # Detect the point where we start on the auxiliary macros 278 if ($macrofile eq &get_macrofile_name($targetlang, "2") && $currentfile eq "1") { 266 279 # Write the macros for the package just finished 267 280 &write_macros(TARGET_DM_FILE, $currentpackage, $textmacros, $iconmacros); -
trunk/gsdl/bin/script/translator.pl
r4118 r4125 34 34 35 35 36 use util; 36 37 use GDBM_File; 37 38 use CGI; … … 66 67 # If the source language is not English, it may not be up to date 67 68 if ($sourcelang !~ m/english/) { 68 # print STDERR "Warning: Source language is not English. You should check that" . 69 # " the source language is up to date before beginning.\n"; 70 } 71 72 # Handles cases where the macro file name is different to the language name 73 $sourcelang = "port" if ($sourcelang =~ m/portuguese/); 74 $sourcelang = "indo" if ($sourcelang =~ m/indonesian/); 75 $targetlang = "port" if ($targetlang =~ m/portuguese/); 76 $targetlang = "indo" if ($targetlang =~ m/indonesian/); 77 78 my $gsdldir = "$ENV{'GSDLHOME'}/"; 79 my $macrosdir = $gsdldir . "macros/"; 69 print STDERR "Warning: Source language is not English. You should check that" . 70 " the source language is up to date before beginning.\n"; 71 } 72 73 my $gsdldir = "$ENV{'GSDLHOME'}"; 74 my $macrosdir = util::filename_cat($gsdldir, "macros"); 80 75 81 76 # Check that the source language macro files exist, and parse them 82 my $sourcedmfile1 = $sourcelang . ".dm"; 83 my $sourcehash1; 84 if (-e $macrosdir.$sourcedmfile1) { 85 $sourcehash1 = &parse_macrofile($macrosdir, $sourcedmfile1); 86 } 87 88 my $sourcedmfile2 = $sourcelang . "2.dm"; 89 my $sourcehash2; 90 if (-e $macrosdir.$sourcedmfile2) { 91 $sourcehash2 = &parse_macrofile($macrosdir, $sourcedmfile2); 92 } 77 my $sourcedmname1 = &get_macrofile_name($sourcelang, ""); 78 my $sourcehash1 = &parse_macrofile($macrosdir, $sourcedmname1); 79 my $sourcedmname2 = &get_macrofile_name($sourcelang, "2"); 80 my $sourcehash2 = &parse_macrofile($macrosdir, $sourcedmname2); 93 81 94 82 # Make sure some macros exist to be translated … … 99 87 # Combine the two source hashes 100 88 my $sourcehash = &combine_hashes($sourcehash1, $sourcehash2); 101 # print "Source hash:\n";102 # &display_hash($sourcehash);103 89 104 90 # Check if this is a new translation process or the continuation of an old one 105 $translationdir = $gsdldir . "tmp/lang/" . $sourcelang . "-" . $targetlang . "/";106 $translationdb = $translationdir . "translation.db";107 $updatedb = $translationdir . "update.db";91 $translationdir = util::filename_cat($gsdldir, "tmp", "lang", "$sourcelang-$targetlang"); 92 $translationdb = util::filename_cat($translationdir, "translation.db"); 93 $updatedb = util::filename_cat($translationdir, "update.db"); 108 94 109 95 if (! -e $translationdir) { 110 # Create a directory to store the data for the new translation 96 # Create a directory to store the data for the new translation, make world-writeable 97 my $currentmask = umask; 98 umask(0000); 111 99 if (! mkdir($translationdir, 0777)) { 100 umask($currentmask); 112 101 die "Error: Couldn't create directory $translationdir.\n"; 113 102 } 103 umask($currentmask); 114 104 115 105 # Start a new database for the translation information … … 117 107 118 108 # Work out what the target language code should be, and store it in the database 119 my $langdir = $gsdldir . "tmp/lang/"; 120 my $langlogfile = $langdir . "languages.log"; 109 my $maincfgfile = util::filename_cat($gsdldir, "etc", "main.cfg"); 121 110 my $languagecodes = &get_language_codes(); 122 my $targetcode = &get_language_code($targetlang, $langlogfile, $languagecodes); 123 print STDERR "Target language code: $targetcode\n"; 111 my $targetcode = &get_language_code($targetlang, $maincfgfile, $languagecodes); 124 112 $translationdata{"*target_lang_code*"} = $targetcode; 125 113 … … 134 122 135 123 # Create the target language macro files if they don't exist 136 my $targetdmfile1 = $targetlang . ".dm"; 137 if (! -e $macrosdir.$targetdmfile1) { 138 # print "Target macro file $macrosdir$targetdmfile1 does not exist... creating.\n"; 139 &create_empty_macrofile($macrosdir.$sourcedmfile1, $macrosdir.$targetdmfile1); 140 } 141 my $targetdmfile2 = $targetlang . "2.dm"; 142 if (! -e $macrosdir.$targetdmfile2) { 143 # print "Target macro file $macrosdir$targetdmfile2 does not exist... creating.\n"; 144 &create_empty_macrofile($macrosdir.$sourcedmfile2, $macrosdir.$targetdmfile2); 124 my $targetdmname1 = &get_macrofile_name($targetlang, ""); 125 my $targetdmfile1 = util::filename_cat($macrosdir, $targetdmname1); 126 if (! -e $targetdmfile1) { 127 my $sourcedmfile1 = util::filename_cat($macrosdir, $sourcedmname1); 128 &create_empty_macrofile($sourcedmfile1, $targetdmfile1); 129 } 130 my $targetdmname2 = &get_macrofile_name($targetlang, "2"); 131 my $targetdmfile2 = util::filename_cat($macrosdir, $targetdmname2); 132 if (! -e $targetdmfile2) { 133 my $sourcedmfile2 = util::filename_cat($macrosdir, $sourcedmname2); 134 &create_empty_macrofile($sourcedmfile2, $targetdmfile2); 145 135 } 146 136 147 137 # Parse the target language macro files 148 my $targethash1 = &parse_macrofile($macrosdir, $targetdm file1);149 my $targethash2 = &parse_macrofile($macrosdir, $targetdm file2);138 my $targethash1 = &parse_macrofile($macrosdir, $targetdmname1); 139 my $targethash2 = &parse_macrofile($macrosdir, $targetdmname2); 150 140 151 141 # Combine the two target hashes 152 142 my $targethash = &combine_hashes($targethash1, $targethash2); 153 # print "Target hash:\n";154 # &display_hash($targethash);155 143 156 144 # Determine the macros that need translating 157 145 my $needstranslating = &find_macros_needing_translation($sourcelang, $sourcehash, 158 146 $targetlang, $targethash); 159 # print "Macros needing translation:\n";160 # &display_hash($needstranslating);161 147 162 148 # Generates HTML code to display user interface on webpage with what needs translation 163 &generate_pages($sourcelang, $targetlang, $needstranslating); 149 my $targetcode = $translationdata{"*target_lang_code*"}; 150 print STDERR "Target language code: $targetcode\n"; 151 &generate_pages($sourcelang, $targetlang, $targetcode, $needstranslating); 164 152 165 153 # Clean up … … 169 157 170 158 159 sub get_macrofile_name 160 { 161 my ($language, $suffix) = @_; 162 163 my $macrofilename = $language; 164 165 # Handles cases where the macro file name is different to the language name 166 $macrofilename = "port" if ($language =~ m/portuguese/); 167 $macrofilename = "indo" if ($language =~ m/indonesian/); 168 169 # Add suffix (if any) and file extension, and return 170 $macrofilename = $macrofilename . $suffix . ".dm"; 171 return $macrofilename; 172 } 173 174 171 175 sub get_language_code 172 176 { 173 my ($language, $langlogfile, $languagecodes) = @_; 174 175 # Try the languages.log file 176 open(LANG_LOG_IN, "<$langlogfile") or die "Error: Could not open $langlogfile.\n"; 177 178 my $linenum = "odd"; 179 my $found = "false"; 180 while (<LANG_LOG_IN>) { 177 my ($language, $maincfgfile, $languagecodes) = @_; 178 179 # Check if the language is in the main.cfg file 180 open(MAIN_CFG_IN, "<$maincfgfile") or die "Error: Could not open $maincfgfile.\n"; 181 my $lastlangline; 182 while (<MAIN_CFG_IN>) { 181 183 $line = $_; 182 184 chomp($line); 183 184 # Check if the language code appears in the languages.log file 185 if ($linenum eq "odd") { 186 if ($line eq $language) { 187 $found = "true"; 185 # print "Line: $line\n"; 186 if ($line =~ m/^Language\s+/i) { 187 my @args = split(/ +/,$line); 188 my ($lang_abbr) = ($args[1] =~ m/^shortname=(.*)$/); 189 $lang_abbr =~ tr/A-Z/a-z/; 190 my ($lang_long) = ($args[2] =~ m/^longname=(.*)$/); 191 $lang_long =~ tr/A-Z/a-z/; 192 193 # Is this the language we are translating into? 194 if ($lang_long eq $language) { 195 return $lang_abbr; 188 196 } 189 $linenum = "even"; 190 } 191 else { 192 if ($found eq "true") { 193 return $line; 194 } 195 $linenum = "odd"; 196 } 197 } 198 199 close LANG_LOG_IN; 197 198 $lastlangline = $line; 199 } 200 } 201 close MAIN_CFG_IN; 200 202 201 203 # Try to find it using the ISO 639 language codes … … 209 211 } 210 212 211 # Add the language code to the languages.log file 212 open LANG_LOG_OUT, ">>$langlogfile" or die "Error: Could not append to $langlogfile.\n"; 213 print LANG_LOG_OUT "\n$language\n$langcode"; 214 close LANG_LOG_OUT; 213 # Add the new language code into the main.cfg file 214 open MAIN_CFG_OUT, ">$maincfgfile.new" or die "Error: Could not write $maincfgfile.new\n"; 215 open MAIN_CFG_IN, "<$maincfgfile" or die "Error: Could not open $maincfgfile.\n"; 216 my $inmacros = "false"; 217 while (<MAIN_CFG_IN>) { 218 $line = $_; 219 chomp($line); 220 print MAIN_CFG_OUT $line; 221 if ($line =~ m/^macrofiles /) { 222 $inmacros = "true"; 223 } 224 if ($inmacros eq "true" && $line !~ m/\\$/) { 225 print MAIN_CFG_OUT " \\\n"; 226 print MAIN_CFG_OUT " $language" . ".dm $language" . "2.dm"; 227 $inmacros = "false"; 228 } 229 print MAIN_CFG_OUT "\n"; 230 231 if ($line eq $lastlangline) { 232 # Change language into title case 233 my $langtitlecase = $language; 234 substr($langtitlecase, 0, 1) =~ tr/a-z/A-Z/; 235 print MAIN_CFG_OUT ("Language shortname=$langcode longname=$langtitlecase ", 236 "default_encoding=utf-8\n"); 237 } 238 } 239 close MAIN_CFG_IN; 240 close MAIN_CFG_OUT; 241 242 # Delete the old main.cfg and replace it with the new one 243 unlink($maincfgfile); 244 rename("$maincfgfile.new", $maincfgfile); 215 245 216 246 return $langcode; … … 261 291 my ($macrosdir, $macrofile) = @_; 262 292 293 # Opens macro file or returns 294 my $macropath = util::filename_cat($macrosdir, $macrofile); 295 open(IN, "<$macropath") or return; 296 263 297 # Initialises some local variables 264 298 my $currpackage; 265 299 my %macros = (); 266 267 # Opens macro file or returns268 my $macropath = $macrosdir . $macrofile;269 open(IN, "<$macropath") or return;270 300 271 301 # Reads in contents of macro file, line by line … … 357 387 358 388 359 sub display_hash360 {361 my ($hash) = @_;362 363 foreach $key (sort (keys %$hash)) {364 print $key . "\n";365 print $hash->{$key} . "\n";366 }367 }368 369 370 389 sub find_macros_needing_translation 371 390 { … … 377 396 if ($translationdata{$sourcekey} ne $sourcehash->{$sourcekey}) { 378 397 # print "Source macro $sourcekey has changed value.\n"; 379 380 my $targetkey = &get_target_key_equivalent($sourcelang, $targetlang, 381 $sourcekey); 398 my $targetkey = &get_macroname_equivalent($sourcelang, $targetlang, 399 $sourcekey); 382 400 if ($targethash->{$targetkey}) { 383 401 $updatedata{$targetkey} = $targethash->{$targetkey}; … … 409 427 410 428 # Macros that need translating are those that are in the source language macro file 411 # but no translation exists in the translation database 429 # but no translation exists in the translation database... 412 430 foreach $sourcekey (sort keys(%$sourcehash)) { 413 my $targetkey = &get_ target_key_equivalent($sourcelang, $targetlang, $sourcekey);431 my $targetkey = &get_macroname_equivalent($sourcelang, $targetlang, $sourcekey); 414 432 if (!$translationdata{$targetkey}) { 415 433 # print "Macro $sourcekey needs translating.\n"; … … 421 439 # ...and those in the list of macros to update 422 440 foreach $targetkey (sort keys(%updatedata)) { 423 my $sourcekey = &get_ source_key_equivalent($sourcelang, $targetlang, $targetkey);441 my $sourcekey = &get_macroname_equivalent($targetlang, $sourcelang, $targetkey); 424 442 $needstranslating{$sourcekey}[0] = $sourcehash->{$sourcekey}; 425 443 $needstranslating{$sourcekey}[1] = $updatedata{$targetkey}; … … 430 448 431 449 432 sub get_ source_key_equivalent433 { 434 my ($ sourcelang, $targetlang, $targetkey) = @_;435 436 my $macrofile = $ targetkey;450 sub get_macroname_equivalent 451 { 452 my ($languageA, $languageB, $languageAkey) = @_; 453 454 my $macrofile = $languageAkey; 437 455 $macrofile =~ s/^([^:]+)::(.*)/$1/; 438 my $key = $ targetkey;456 my $key = $languageAkey; 439 457 $key =~ s/^([^:])+::(.*)/$2/; 440 458 441 my $sourcekey; 442 if ($macrofile eq ($targetlang . ".dm")) { 443 $sourcekey = $sourcelang . ".dm" . "::" . $key; 444 } 445 if ($macrofile eq ($targetlang . "2.dm")) { 446 $sourcekey = $sourcelang . "2.dm" . "::" . $key; 447 } 448 449 return ($sourcekey); 450 } 451 452 453 sub get_target_key_equivalent 454 { 455 my ($sourcelang, $targetlang, $sourcekey) = @_; 456 457 my $macrofile = $sourcekey; 458 $macrofile =~ s/^([^:]+)::(.*)/$1/; 459 my $key = $sourcekey; 460 $key =~ s/^([^:])+::(.*)/$2/; 461 462 my $targetkey; 463 if ($macrofile eq ($sourcelang . ".dm")) { 464 $targetkey = $targetlang . ".dm" . "::" . $key; 465 } 466 if ($macrofile eq ($sourcelang . "2.dm")) { 467 $targetkey = $targetlang . "2.dm" . "::" . $key; 468 } 469 470 return ($targetkey); 459 my $languageBkey; 460 if ($macrofile eq &get_macrofile_name($languageA, "")) { 461 $languageBkey = &get_macrofile_name($languageB, "") . "::" . $key; 462 } 463 if ($macrofile eq &get_macrofile_name($languageA, "2")) { 464 $languageBkey = &get_macrofile_name($languageB, "2") . "::" . $key; 465 } 466 467 return ($languageBkey); 471 468 } 472 469 … … 476 473 sub generate_pages 477 474 { 478 my ($sourcelang, $targetlang, $ needstranslating) = @_;475 my ($sourcelang, $targetlang, $targetcode, $needstranslating) = @_; 479 476 480 477 my %pagehash = (); 481 478 482 @page no= ();479 @pages = (); 483 480 $pageno = 1; 484 481 $keysperpage = 0; … … 493 490 #each macro is associated with some macrotext and whether it was from the core 494 491 #or auxiliary macrofile 495 # my $targetkey = &get_target_key_equivalent($sourcelang, $targetlang, $sourcekey);496 # print "Source key: $sourcekey Target key: $targetkey\n";497 498 492 $pagehash->{$pageno}->{$sourcekey} = $needstranslating->{$sourcekey}; 499 493 $keysperpage++; 500 494 501 #reduce the number of macros per page in these cases 502 # $limit = 7 if($key =~ m/collector::_text.*/); 503 # $limit = 7 if($key =~ m/help::_text.*/); 504 # $limit = 1 if($key =~ m/translang::_textinitial_/); 505 # $limit = 3 if($key =~ m/home::.*/); 506 # $limit = 3 if($key =~ m/gsdl::.*/); 507 # $limit = 1 if($key =~ m/help::_(.*)texthelp.*/); 508 # $limit = $keysperpage if ($limit <= $keysperpage); 509 510 #if have enough keys to generate a page with 495 # If have enough keys to generate a page with 511 496 if ($keysperpage == $limit) { 512 497 #opens a file to write the HTML code to for current page 513 open HTMLFILE, ">$translationdir/$pageno.lang"; 498 my $transpagefile = util::filename_cat($translationdir, $pageno . ".lang"); 499 open HTMLFILE, ">$transpagefile"; 514 500 515 501 #passes hash of keys for current page and filehandle, returns CGI data 516 &generate_form($sourcelang, $targetlang, $pagehash->{$pageno}, \*HTMLFILE); 502 &generate_form($sourcelang, $targetlang, $targetcode, 503 $pagehash->{$pageno}, \*HTMLFILE); 517 504 close HTMLFILE; 518 505 519 506 #push the page number onto the array of pages 520 push(@page no, $pageno);507 push(@pages, $pageno); 521 508 $pageno++; 522 509 … … 530 517 if ($keysperpage != 0) { 531 518 # writes out the remaining keys, same format as above 532 open HTMLFILE, ">$translationdir/$pageno.lang"; 533 &generate_form($sourcelang, $targetlang, $pagehash->{$pageno}, \*HTMLFILE); 519 my $transpagefile = util::filename_cat($translationdir, $pageno . ".lang"); 520 open HTMLFILE, ">$transpagefile"; 521 &generate_form($sourcelang, $targetlang, $targetcode, $pagehash->{$pageno}, \*HTMLFILE); 534 522 close HTMLFILE; 535 push(@page no, $pageno);536 } 537 538 # writes each page numberto a file539 open PAGELOG, ">$translationdir/pageno.log";540 foreach $page (@pageno) {541 print PAGELOG $page, "\n";542 }543 close PAGELOG; 544 545 #write thankyou page for language translator once translation is complete546 open THANKYOU, ">$t ranslationdir/thankyou.lang" or die("MURGH\n");523 push(@pages, $pageno); 524 } 525 526 # Write the number of pages to a file 527 my $numpagesfile = util::filename_cat($translationdir, "numpages.log"); 528 open NUMPAGESLOG, ">$numpagesfile" or die "Error: Could not write $numpagesfile.\n"; 529 print NUMPAGESLOG ($pageno - 1); 530 close NUMPAGESLOG; 531 532 # Write thankyou page for language translator once translation is complete 533 my $thankyoufile = util::filename_cat($translationdir, "thankyou.lang"); 534 open THANKYOU, ">$thankyoufile" or die "Error: Could not write $thankyoufile.\n"; 547 535 print THANKYOU ("<center> _textthanks_ $targetlang _texttrans_ _textgetdmfiles_ ", 548 536 "<a href=\"_httpprefix_/gsdl/macros/$targetlang" . ".dm\">_texthere_</a>", … … 551 539 "<p></center>\n"); 552 540 close THANKYOU; 553 554 #returns CGI data555 return @queries;556 541 } 557 542 … … 561 546 my $sourcelang = shift(@_); 562 547 my $targetlang = shift(@_); 548 my $targetcode = shift(@_); 563 549 my $formhash = shift(@_); 564 550 my $fh = shift(@_); … … 569 555 570 556 $first = "true"; 571 572 557 foreach $key (sort (keys(%$formhash))) { 573 558 … … 734 719 $query->submit($pageno, "_textsubmit_"), 735 720 "</td></tr><tr><td width=\"50%\"></td><td align=right width=\"50%\">", 736 "<br> _textsubmittext_ \n", 737 "_textgetdmfiles_ ", 738 "<a href=\"_httpprefix_/gsdl/macros/$targetlang" . ".dm\">_texthere_</a>", 739 " & ", 740 "<a href=\"_httpprefix_/gsdl/macros/$targetlang" . "2.dm\">_texthere_</a>.", 721 "<br> _textsubmittext_ ", 722 "<a href=\"_gwcgi_?a=p&p=home&l=$targetcode\">_texthere_</a>.", 723 # "_textgetdmfiles_ ", 724 # "<a href=\"_httpprefix_/gsdl/macros/$targetlang" . ".dm\">_texthere_</a>", 725 # " & ", 726 # "<a href=\"_httpprefix_/gsdl/macros/$targetlang" . "2.dm\">_texthere_</a>.", 741 727 "</td></tr></table>"); 742 743 # adds the CGI area just written to the array of CGI areas744 push (@queries, $query);745 746 # return $query;747 728 } 748 729 … … 776 757 if ($macrofile eq ($sourcelang . "2.dm")) { 777 758 return "2"; # Auxiliary macro 759 } 760 } 761 762 763 sub display_hash 764 { 765 my ($hash) = @_; 766 767 foreach $key (sort (keys %$hash)) { 768 print $key . "\n"; 769 print $hash->{$key} . "\n"; 778 770 } 779 771 }
Note:
See TracChangeset
for help on using the changeset viewer.