Changeset 18460 for gsdl/trunk
- Timestamp:
- 2009-02-04T15:02:01+13:00 (15 years ago)
- Location:
- gsdl/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/gti.pl
r14258 r18460 89 89 # 'target_file' => "greenorg/macros/{iso_639_1_target_language_name}.dm" 90 90 } 91 92 # { 'key' => "gs3interface", 93 #'file_type' => "resource_bundle", 94 #'source_file' => "greenstone3", 95 #'target_file' => "greenstone3" 96 #} 91 97 ]; 98 99 my @gs3_interface_files = ("AbstractBrowse", "AbstractGS2FieldSearch", "Authentication", "CrossCollectionSearch", "GATEServices", "GS2Construct", "GS2LuceneSearch", "interface_default", "interface_nzdl", "IViaSearch", "LuceneSearch", "MapRetrieve", "MapSearch", "metadata_names", "PhindPhraseBrowse", "QBRWebServicesHelp", "Visualizer"); 92 100 93 101 … … 97 105 my $gti_command = shift(@_); 98 106 my @gti_command_arguments = @_; 107 my $module = $_[1]; 99 108 100 109 # Open the GTI log file for appending, or write to STDERR if that fails … … 109 118 if (!$gti_command) { 110 119 &throw_fatal_error("Missing command."); 111 } 120 } 112 121 113 122 # Process the command 114 123 if ($gti_command =~ /^get-all-chunks$/i) { 115 print &get_all_chunks(@gti_command_arguments); 124 # Check that GS3 interface is the target 125 if ($module eq "gs3interface") { 126 print &get_all_chunks_for_gs3(@gti_command_arguments); 127 } else { 128 print &get_all_chunks(@gti_command_arguments); 129 } 116 130 } 117 131 if ($gti_command =~ /^get-first-n-chunks-requiring-work$/i) { 118 print &get_first_n_chunks_requiring_work(@gti_command_arguments); 132 if ($module eq "gs3interface") { 133 print &get_first_n_chunks_requiring_work_for_gs3(@gti_command_arguments); 134 } else { 135 print &get_first_n_chunks_requiring_work(@gti_command_arguments); 136 } 119 137 } 120 138 if ($gti_command =~ /^get-language-status$/i) { … … 128 146 &submit_translations(@gti_command_arguments); 129 147 } 130 131 # The command was not recognized 132 # &throw_fatal_error("Unknown command \"$gti_command\"."); 148 if ($gti_command =~ /^create-glihelp-zip-file$/i) { 149 # This command cannot produce any output since it reads input 150 &create_glihelp_zip_file(@gti_command_arguments); 151 } 152 # else { 153 # The command was not recognized 154 #&throw_fatal_error("Unknown command \"$gti_command\"."); 155 #} 133 156 } 134 157 … … 197 220 my %source_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($source_file, \@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 198 221 my %target_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($target_file, \@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 199 200 # Form an XML response to the command 201 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 202 $xml_response .= "<GTIResponse>\n"; 203 $xml_response .= " <TranslationFile" 204 . " key=\"" . $translation_file_key . "\"" 205 . " target_file_path=\"" . $target_file . "\"\/>\n"; 206 207 # Do all the chunks 208 $xml_response .= " <Chunks size=\"" . scalar(keys(%source_file_key_to_text_mapping)) . "\">\n"; 209 foreach my $chunk_key (keys(%source_file_key_to_text_mapping)) { 210 my $source_file_chunk_date = $source_file_key_to_last_update_date_mapping{$chunk_key}; 211 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}); 212 213 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 214 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 215 if (defined($target_file_key_to_text_mapping{$chunk_key})) { 216 my $target_file_chunk_date = $target_file_key_to_last_update_date_mapping{$chunk_key}; 217 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping{$chunk_key}); 218 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; 219 } 220 else { 221 $xml_response .= " <TargetFileText></TargetFileText>\n"; 222 } 223 224 $xml_response .= " </Chunk>\n"; 225 } 226 $xml_response .= " </Chunks>\n"; 227 228 $xml_response .= "</GTIResponse>\n"; 222 223 my $xml_response = &create_xml_response_for_all_chunks($translation_file_key, $target_file, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, \%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping); 224 229 225 return $xml_response; 230 226 } … … 281 277 &log_message("Number of target chunks requiring updating: " . scalar(@target_file_keys_requiring_updating)); 282 278 283 # Form an XML response to the command 284 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 285 $xml_response .= "<GTIResponse>\n"; 286 $xml_response .= " <TranslationFile" 287 . " key=\"" . $translation_file_key . "\"" 288 . " target_file_path=\"" . $target_file . "\"" 289 . " num_chunks_translated=\"" . (scalar(keys(%source_file_key_to_text_mapping)) - scalar(@target_file_keys_requiring_translation)) . "\"" 290 . " num_chunks_requiring_translation=\"" . scalar(@target_file_keys_requiring_translation) . "\"" 291 . " num_chunks_requiring_updating=\"" . scalar(@target_file_keys_requiring_updating) . "\"\/>\n"; 292 293 # Do chunks requiring translation first 294 if ($num_chunks_to_return > scalar(@target_file_keys_requiring_translation)) { 295 $xml_response .= " <ChunksRequiringTranslation size=\"" . scalar(@target_file_keys_requiring_translation) . "\">\n"; 296 } 297 else { 298 $xml_response .= " <ChunksRequiringTranslation size=\"" . $num_chunks_to_return . "\">\n"; 299 } 300 301 foreach my $chunk_key (@target_file_keys_requiring_translation) { 302 last if ($num_chunks_to_return == 0); 303 304 my $source_file_chunk_date = $source_file_key_to_last_update_date_mapping{$chunk_key}; 305 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}); 306 307 if(!defined $source_file_chunk_date){ 308 $source_file_chunk_date = ""; 309 } 310 311 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 312 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 313 $xml_response .= " <TargetFileText></TargetFileText>\n"; 314 $xml_response .= " </Chunk>\n"; 315 316 $num_chunks_to_return--; 317 } 318 319 $xml_response .= " </ChunksRequiringTranslation>\n"; 320 321 # Then do chunks requiring updating 322 if ($num_chunks_to_return > scalar(@target_file_keys_requiring_updating)) { 323 $xml_response .= " <ChunksRequiringUpdating size=\"" . scalar(@target_file_keys_requiring_updating) . "\">\n"; 324 } 325 else { 326 $xml_response .= " <ChunksRequiringUpdating size=\"" . $num_chunks_to_return . "\">\n"; 327 } 328 329 foreach my $chunk_key (@target_file_keys_requiring_updating) { 330 last if ($num_chunks_to_return == 0); 331 332 my $source_file_chunk_date = $source_file_key_to_last_update_date_mapping{$chunk_key}; 333 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}); 334 my $target_file_chunk_date = $target_file_key_to_last_update_date_mapping{$chunk_key}; 335 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping{$chunk_key}); 336 337 if(!defined $source_file_chunk_date){ 338 $source_file_chunk_date = ""; 339 } 340 341 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 342 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 343 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; 344 $xml_response .= " </Chunk>\n"; 345 346 $num_chunks_to_return--; 347 } 348 349 $xml_response .= " </ChunksRequiringUpdating>\n"; 350 351 $xml_response .= "</GTIResponse>\n"; 279 my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, $target_file, scalar(keys(%source_file_key_to_text_mapping)), \@target_file_keys_requiring_translation, \@target_file_keys_requiring_updating, $num_chunks_to_return, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, \%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping); 280 352 281 return $xml_response; 353 282 } … … 369 298 $xml_response .= " <LanguageStatus code=\"$target_language_code\">\n"; 370 299 371 foreach my $translation_file (@$gti_translation_files) { 300 foreach my $translation_file (@$gti_translation_files) { 301 my ($num_source_chunks, $num_target_chunks, $num_chunks_requiring_translation, $num_chunks_requiring_updating) = 0; 302 my $target_file_name = ""; 303 304 if ($translation_file->{'key'} eq "gs3interface") { 305 my (%source_file_key_to_text_mapping, %target_file_key_to_text_mapping, %source_file_key_to_last_update_date_mapping, %target_file_key_to_last_update_date_mapping ) = (); 306 &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, \%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping ); 307 308 my @target_file_keys_requiring_translation = &determine_chunks_requiring_translation(\%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping); 309 my @target_file_keys_requiring_updating = &determine_chunks_requiring_updating(\%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping); 310 311 $num_source_chunks = scalar(keys(%source_file_key_to_text_mapping)); 312 $num_target_chunks = scalar(keys(%target_file_key_to_text_mapping)); 313 $num_chunks_requiring_translation = scalar(@target_file_keys_requiring_translation); 314 $num_chunks_requiring_updating = scalar(@target_file_keys_requiring_updating); 315 } 316 else { 317 # Get (and check) the translation configuration 318 my ($source_file, $target_file, $translation_file_type) = &get_translation_configuration($target_language_code, $translation_file->{'key'}); 319 $target_file_name = $target_file; 320 321 # Parse the source language and target language files 322 my $source_file_path = &util::filename_cat($gsdl_root_directory, $source_file); 323 my @source_file_lines = &read_file_lines($source_file_path); 324 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 325 326 my $target_file_path = &util::filename_cat($gsdl_root_directory, $target_file); 327 my @target_file_lines = &read_file_lines($target_file_path); 328 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type); 329 330 # Filter out any automatically translated chunks 331 foreach my $chunk_key (keys(%source_file_key_to_line_mapping)) { 332 if (&is_chunk_automatically_translated($chunk_key, $translation_file_type)) { 333 delete $source_file_key_to_line_mapping{$chunk_key}; 334 delete $target_file_key_to_line_mapping{$chunk_key}; 335 } 336 } 337 338 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 339 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 340 341 # Determine the target file chunks requiring translation 342 my @target_file_keys_requiring_translation = &determine_chunks_requiring_translation(\%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping); 343 344 # Determine the target file chunks requiring updating 345 my @target_file_keys_requiring_updating = (); 346 if (-e $target_file_path) { 347 my %source_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($source_file, \@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 348 my %target_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($target_file, \@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 349 @target_file_keys_requiring_updating = &determine_chunks_requiring_updating(\%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping); 350 } 351 352 $num_source_chunks = scalar(keys(%source_file_key_to_text_mapping)); 353 $num_target_chunks = scalar(keys(%target_file_key_to_text_mapping)); 354 $num_chunks_requiring_translation = scalar(@target_file_keys_requiring_translation); 355 $num_chunks_requiring_updating = scalar(@target_file_keys_requiring_updating); 356 } 357 358 &log_message("Status of " . $translation_file->{'key'}); 359 &log_message("Number of source chunks: " . $num_source_chunks); 360 &log_message("Number of target chunks: " . $num_target_chunks); 361 &log_message("Number of target chunks requiring translation: " . $num_chunks_requiring_translation); 362 &log_message("Number of target chunks requiring updating: " . $num_chunks_requiring_updating); 363 364 $xml_response .= " <TranslationFile" 365 . " key=\"" . $translation_file->{'key'} . "\"" 366 . " target_file_path=\"" . $target_file_name . "\"" 367 . " num_chunks_translated=\"" . ($num_source_chunks - $num_chunks_requiring_translation) . "\"" 368 . " num_chunks_requiring_translation=\"" . $num_chunks_requiring_translation . "\"" 369 . " num_chunks_requiring_updating=\"" . $num_chunks_requiring_updating . "\"\/>\n"; 370 } 371 372 $xml_response .= " </LanguageStatus>\n"; 373 374 $xml_response .= "</GTIResponse>\n"; 375 return $xml_response; 376 } 377 378 379 sub search_chunks 380 { 381 # The code of the target language (ensure it is lowercase) 382 my $target_language_code = lc(shift(@_)); 383 # The key of the file to translate (ensure it is lowercase) 384 my $translation_file_key = lc(shift(@_)); 385 # The query string 386 my $query_string = join(' ', @_); 387 388 # Check that the necessary arguments were supplied 389 if (!$target_language_code || !$translation_file_key || !$query_string) { 390 &throw_fatal_error("Missing command argument."); 391 } 392 393 my ($source_file, $target_file, $translation_file_type) = (); 394 my %source_file_key_to_text_mapping = (); 395 my %target_file_key_to_text_mapping = (); 396 397 398 if ($translation_file_key ne "gs3interface") { 372 399 # Get (and check) the translation configuration 373 my ($source_file, $target_file, $translation_file_type) 374 = &get_translation_configuration($target_language_code, $translation_file->{'key'}); 400 ($source_file, $target_file, $translation_file_type) = &get_translation_configuration($target_language_code, $translation_file_key); 375 401 376 402 # Parse the source language and target language files … … 391 417 } 392 418 393 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 394 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 395 &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping))); 396 &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping))); 397 398 # Determine the target file chunks requiring translation 399 my @target_file_keys_requiring_translation = &determine_chunks_requiring_translation(\%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping); 400 &log_message("Number of target chunks requiring translation: " . scalar(@target_file_keys_requiring_translation)); 401 402 # Determine the target file chunks requiring updating 403 my @target_file_keys_requiring_updating = (); 404 if (-e $target_file_path) { 405 my %source_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($source_file, \@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 406 my %target_file_key_to_last_update_date_mapping = &build_key_to_last_update_date_mapping($target_file, \@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 407 @target_file_keys_requiring_updating = &determine_chunks_requiring_updating(\%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping); 408 &log_message("Number of target chunks requiring updating: " . scalar(@target_file_keys_requiring_updating)); 409 } 410 411 $xml_response .= " <TranslationFile" 412 . " key=\"" . $translation_file->{'key'} . "\"" 413 . " target_file_path=\"" . $target_file . "\"" 414 . " num_chunks_translated=\"" . (scalar(keys(%source_file_key_to_text_mapping)) - scalar(@target_file_keys_requiring_translation)) . "\"" 415 . " num_chunks_requiring_translation=\"" . scalar(@target_file_keys_requiring_translation) . "\"" 416 . " num_chunks_requiring_updating=\"" . scalar(@target_file_keys_requiring_updating) . "\"\/>\n"; 417 } 418 419 $xml_response .= " </LanguageStatus>\n"; 420 421 $xml_response .= "</GTIResponse>\n"; 422 return $xml_response; 423 } 424 425 426 sub search_chunks 427 { 428 # The code of the target language (ensure it is lowercase) 429 my $target_language_code = lc(shift(@_)); 430 # The key of the file to translate (ensure it is lowercase) 431 my $translation_file_key = lc(shift(@_)); 432 # The query string 433 my $query_string = join(' ', @_); 434 435 # Check that the necessary arguments were supplied 436 if (!$target_language_code || !$translation_file_key || !$query_string) { 437 &throw_fatal_error("Missing command argument."); 438 } 439 440 # Get (and check) the translation configuration 441 my ($source_file, $target_file, $translation_file_type) 442 = &get_translation_configuration($target_language_code, $translation_file_key); 443 444 # Parse the source language and target language files 445 my $source_file_path = &util::filename_cat($gsdl_root_directory, $source_file); 446 my @source_file_lines = &read_file_lines($source_file_path); 447 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 448 449 my $target_file_path = &util::filename_cat($gsdl_root_directory, $target_file); 450 my @target_file_lines = &read_file_lines($target_file_path); 451 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type); 452 453 # Filter out any automatically translated chunks 454 foreach my $chunk_key (keys(%source_file_key_to_line_mapping)) { 455 if (&is_chunk_automatically_translated($chunk_key, $translation_file_type)) { 456 delete $source_file_key_to_line_mapping{$chunk_key}; 457 delete $target_file_key_to_line_mapping{$chunk_key}; 458 } 459 } 460 461 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 462 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 419 %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 420 %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 421 } 422 else { 423 # Not needed in this case 424 my (%source_file_key_to_gti_command_mapping, %target_file_key_to_gti_command_mapping) = (); 425 &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, 426 \%source_file_key_to_gti_command_mapping, \%target_file_key_to_gti_command_mapping); 427 } 428 463 429 &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping))); 464 430 &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping))); … … 509 475 die "\n"; 510 476 } 511 512 # Get (and check) the translation configuration 513 my ($source_file, $target_file, $translation_file_type) 514 = &get_translation_configuration($target_language_code, $translation_file_key); 515 516 # Parse the source language and target language files 517 my @source_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $source_file)); 518 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 519 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 520 my %source_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 477 478 my %source_file_key_to_text_mapping = (); 479 my %source_file_key_to_gti_comment_mapping = (); 480 my %target_file_key_to_text_mapping = (); 481 my %target_file_key_to_gti_comment_mapping = (); 482 483 my (@source_file_lines, @target_file_lines) = (); 484 my ($source_file, $target_file, $translation_file_type); 485 486 487 if ($translation_file_key ne "gs3interface") { 488 # Get (and check) the translation configuration 489 ($source_file, $target_file, $translation_file_type) 490 = &get_translation_configuration($target_language_code, $translation_file_key); 491 492 # Parse the source language and target language files 493 @source_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $source_file)); 494 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 495 %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 496 %source_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 497 498 @target_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $target_file)); 499 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type); 500 %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 501 %target_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 502 } 503 else { 504 &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, 505 \%source_file_key_to_gti_comment_mapping, \%target_file_key_to_gti_comment_mapping); 506 } 521 507 &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping))); 522 523 my @target_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $target_file));524 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type);525 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type);526 my %target_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type);527 508 &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping))); 528 509 … … 538 519 539 520 # Remove any nasty carriage returns 540 &log_message("Submission:");521 # &log_message("Submission:"); 541 522 foreach my $submission_line (@submission_lines) { 542 523 $submission_line =~ s/\r$//; 543 &log_message(" $submission_line");524 #&log_message(" $submission_line"); 544 525 } 545 526 … … 561 542 $source_file_chunk_text = &unmake_text_xml_safe($source_file_chunk_text); 562 543 563 &log_message("Source file key: $chunk_key");564 &log_message("Source file text: $source_file_chunk_text");544 #&log_message("Source file key: $chunk_key"); 545 #&log_message("Source file text: $source_file_chunk_text"); 565 546 $source_file_key_to_submission_mapping{$chunk_key} = $source_file_chunk_text; 566 547 } … … 580 561 $target_file_chunk_text = &unmake_text_xml_safe($target_file_chunk_text); 581 562 582 &log_message("Target file key: $chunk_key");583 &log_message("Target file text: $target_file_chunk_text");563 #&log_message("Target file key: $chunk_key"); 564 #&log_message("Target file text: $target_file_chunk_text"); 584 565 $target_file_key_to_submission_mapping{$chunk_key} = $target_file_chunk_text; 585 566 } … … 619 600 } 620 601 } 621 622 eval "&write_translated_${translation_file_type}(\$source_file, \\\@source_file_lines, \\\%source_file_key_to_text_mapping, \$target_file, \\\@target_file_lines, \\\%target_file_key_to_text_mapping, \\\%target_file_key_to_gti_comment_mapping, \$target_language_code)"; 602 603 if ($translation_file_key ne "gs3interface") { 604 eval "&write_translated_${translation_file_type}(\$source_file, \\\@source_file_lines, \\\%source_file_key_to_text_mapping, \$target_file, \\\@target_file_lines, \\\%target_file_key_to_text_mapping, \\\%target_file_key_to_gti_comment_mapping, \$target_language_code)"; 605 } else { 606 eval "&write_translated_gs3interface(\\\%source_file_key_to_text_mapping, \\\%target_file_key_to_text_mapping, \\\%target_file_key_to_gti_comment_mapping, \$target_language_code)"; 607 } 608 } 609 610 611 sub create_glihelp_zip_file 612 { 613 my $target_language_code = shift(@_); 614 my $translation_file_key = "glihelp"; 615 616 &log_message("Creating GLI Help zip file for $target_language_code"); 617 618 my ($source_file, $target_file, $translation_file_type) = &get_translation_data_for($target_language_code, $translation_file_key); 619 620 my $classpath = &util::filename_cat($gsdl_root_directory, "gti-lib"); 621 if ( ! -e $classpath) { 622 &throw_fatal_error("$classpath doesn't exist! Need the files in this directory (ApplyXLST and its related files) to create the zip file for GLI Help"); 623 } 624 625 my $gli_help_directory = &util::filename_cat($gsdl_root_directory, "gli"); 626 $gli_help_directory = &util::filename_cat($gli_help_directory, "help"); 627 628 my $gen_many_html_xsl_filepath = &util::filename_cat($gli_help_directory, "gen-many-html.xsl"); 629 if ( ! -e $gen_many_html_xsl_filepath) { 630 &throw_fatal_error("$gen_many_html_xsl_filepath doesn't exist! Need this file to create the zip file for GLI Help"); 631 } 632 633 my $gen_index_xml_xsl_filepath = &util::filename_cat($gli_help_directory, "gen-index-xml.xsl"); 634 my $split_script_filepath = &util::filename_cat($gli_help_directory, "splithelpdocument.pl"); 635 636 my $target_file_directory = &util::filename_cat($gli_help_directory, $target_language_code); 637 $target_file_directory = $target_file_directory."/"; 638 639 my $target_filepath = &util::filename_cat($gsdl_root_directory, $target_file); 640 my $cmd = "/opt/jdk1.6.0/bin/java -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | perl -S $split_script_filepath $target_file_directory"; 641 my $response = `$cmd`; 642 &log_message($cmd); 643 &log_message($response); 644 &log_message("Created HTML operational files"); 645 646 $cmd = "/opt/jdk1.6.0/bin/java -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null"; 647 $response = `$cmd`; 648 &log_message($cmd); 649 &log_message($response); 650 &log_message("Created xml index file"); 651 652 my $zip_file_path = "/greenstone/custom/gti/" . $target_language_code . "_GLIHelp.zip"; 653 $cmd = "zip -rj $zip_file_path $target_file_directory -i \*.htm \*.xml"; 654 $response = `$cmd`; 655 &log_message($cmd); 656 &log_message($response); 657 &log_message("Created the zip file"); 623 658 } 624 659 … … 767 802 my $chunk_cvs_date = $key_to_cvs_date_mapping{$chunk_key}; 768 803 $key_to_last_update_date_mapping{$chunk_key} = $chunk_cvs_date; 769 804 770 805 # If a comment date exists and it is after the CVS date, use that instead 771 806 # need to convert the comment date format to SVN format … … 773 808 if (defined($chunk_gti_comment) && $chunk_gti_comment =~ /(\d?\d-\D\D\D-\d\d\d\d)/) { 774 809 my $chunk_comment_date = $1; 775 if ((!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date))) { 810 # if the changes were made on 2009 Jan 27, ie. tidying up the GTI commands following each fragment, 811 # then should use the GTI comment date instead 812 # if ((!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date))) { 813 if ((!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date) 814 || (&is_date_after($chunk_cvs_date,$chunk_comment_date) && ($chunk_cvs_date eq "2009-01-27" || $chunk_cvs_date eq "2009-01-28")))) { 776 815 $key_to_last_update_date_mapping{$chunk_key} = $chunk_comment_date; 816 817 # &log_message("cvs date: $chunk_cvs_date, comment date: $chunk_comment_date"); 818 # die; 777 819 } 778 820 } … … 1027 1069 1028 1070 1071 sub create_xml_response_for_chunks_requiring_work 1072 { 1073 my ($translation_file_key, $target_file, $total_num_chunks, $target_files_keys_requiring_translation, $target_files_keys_requiring_updating, $num_chunks_to_return, $source_files_key_to_text_mapping, $target_files_key_to_text_mapping, $source_files_key_to_last_update_date_mapping, $target_files_key_to_last_update_date_mapping) = @_; 1074 1075 # Form an XML response to the command 1076 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 1077 $xml_response .= "<GTIResponse>\n"; 1078 $xml_response .= " <TranslationFile" 1079 . " key=\"" . $translation_file_key . "\"" 1080 . " target_file_path=\"" . $target_file . "\"" 1081 . " num_chunks_translated=\"" . ($total_num_chunks - scalar(@$target_files_keys_requiring_translation)) . "\"" 1082 . " num_chunks_requiring_translation=\"" . scalar(@$target_files_keys_requiring_translation) . "\"" 1083 . " num_chunks_requiring_updating=\"" . scalar(@$target_files_keys_requiring_updating) . "\"\/>\n"; 1084 1085 # Do chunks requiring translation first 1086 if ($num_chunks_to_return > scalar(@$target_files_keys_requiring_translation)) { 1087 $xml_response .= " <ChunksRequiringTranslation size=\"" . scalar(@$target_files_keys_requiring_translation) . "\">\n"; 1088 } 1089 else { 1090 $xml_response .= " <ChunksRequiringTranslation size=\"" . $num_chunks_to_return . "\">\n"; 1091 } 1092 1093 my @sorted_chunk_keys = sort (@$target_files_keys_requiring_translation); 1094 foreach my $chunk_key (@sorted_chunk_keys) { 1095 last if ($num_chunks_to_return == 0); 1096 1097 my $source_file_chunk_date = $source_files_key_to_last_update_date_mapping->{$chunk_key} || ""; 1098 my $source_file_chunk_text = &make_text_xml_safe($source_files_key_to_text_mapping->{$chunk_key}); 1099 1100 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 1101 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 1102 $xml_response .= " <TargetFileText></TargetFileText>\n"; 1103 $xml_response .= " </Chunk>\n"; 1104 1105 $num_chunks_to_return--; 1106 } 1107 1108 $xml_response .= " </ChunksRequiringTranslation>\n"; 1109 1110 # Then do chunks requiring updating 1111 if ($num_chunks_to_return > scalar(@$target_files_keys_requiring_updating)) { 1112 $xml_response .= " <ChunksRequiringUpdating size=\"" . scalar(@$target_files_keys_requiring_updating) . "\">\n"; 1113 } 1114 else { 1115 $xml_response .= " <ChunksRequiringUpdating size=\"" . $num_chunks_to_return . "\">\n"; 1116 } 1117 1118 # foreach my $chunk_key (@target_file_keys_requiring_updating) { 1119 @sorted_chunk_keys = sort (@$target_files_keys_requiring_updating); 1120 foreach my $chunk_key (@sorted_chunk_keys) { 1121 last if ($num_chunks_to_return == 0); 1122 1123 my $source_file_chunk_date = $source_files_key_to_last_update_date_mapping->{$chunk_key} || ""; 1124 my $source_file_chunk_text = &make_text_xml_safe($source_files_key_to_text_mapping->{$chunk_key}); 1125 my $target_file_chunk_date = $target_files_key_to_last_update_date_mapping->{$chunk_key} || ""; 1126 my $target_file_chunk_text = &make_text_xml_safe($target_files_key_to_text_mapping->{$chunk_key}); 1127 1128 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 1129 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 1130 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; 1131 $xml_response .= " </Chunk>\n"; 1132 1133 $num_chunks_to_return--; 1134 } 1135 1136 $xml_response .= " </ChunksRequiringUpdating>\n"; 1137 1138 $xml_response .= "</GTIResponse>\n"; 1139 1140 return $xml_response; 1141 } 1142 1143 1144 sub create_xml_response_for_all_chunks 1145 { 1146 my ($translation_file_key, $target_file, $source_file_key_to_text_mapping, $target_file_key_to_text_mapping, $source_file_key_to_last_update_date_mapping, $target_file_key_to_last_update_date_mapping) = @_; 1147 1148 # Form an XML response to the command 1149 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 1150 $xml_response .= "<GTIResponse>\n"; 1151 $xml_response .= " <TranslationFile" 1152 . " key=\"" . $translation_file_key . "\"" 1153 . " target_file_path=\"" . $target_file . "\"\/>\n"; 1154 1155 # Do all the chunks 1156 $xml_response .= " <Chunks size=\"" . scalar(keys(%$source_file_key_to_text_mapping)) . "\">\n"; 1157 1158 my @sorted_chunk_keys = sort (keys(%$source_file_key_to_text_mapping)); 1159 foreach my $chunk_key (@sorted_chunk_keys) { 1160 my $source_file_chunk_date = $source_file_key_to_last_update_date_mapping->{$chunk_key} || ""; 1161 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping->{$chunk_key}); 1162 1163 $xml_response .= " <Chunk key=\"" . &make_text_xml_safe($chunk_key) . "\">\n"; 1164 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 1165 if (defined($target_file_key_to_text_mapping->{$chunk_key})) { 1166 my $target_file_chunk_date = $target_file_key_to_last_update_date_mapping->{$chunk_key} || ""; 1167 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping->{$chunk_key}); 1168 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; 1169 } 1170 else { 1171 $xml_response .= " <TargetFileText></TargetFileText>\n"; 1172 } 1173 1174 $xml_response .= " </Chunk>\n"; 1175 } 1176 $xml_response .= " </Chunks>\n"; 1177 1178 $xml_response .= "</GTIResponse>\n"; 1179 return $xml_response; 1180 } 1181 1182 1183 1029 1184 # ========================================================================================== 1030 1185 # MACROFILE FUNCTIONS … … 1265 1420 1266 1421 # Line contains a dictionary string 1267 if ($line =~ /^(\S+?) :(.*)$/) {1422 if ($line =~ /^(\S+?)[:|=](.*)$/) { 1268 1423 my $chunk_key = $1; 1269 1424 … … 1282 1437 1283 1438 # Simple: just remove string key 1284 $chunk_text =~ s/^(\S+?) :(\s*)//;1439 $chunk_text =~ s/^(\S+?)[:|=](\s*)//; 1285 1440 $chunk_text =~ s/(\s*)$//; # Remove any nasty whitespace, carriage returns etc. 1286 1441 $chunk_text =~ s/(\s*)\#\s+Updated\s+(\d?\d-\D\D\D-\d\d\d\d.*)\s*$//i; … … 1510 1665 1511 1666 1667 # ========================================================================================== 1668 # GREENSTONE3 FUNCTIONS 1669 1670 sub get_all_chunks_for_gs3 1671 { 1672 # The code of the target language (ensure it is lowercase) 1673 my $target_language_code = lc(shift(@_)); 1674 my $translation_file_key = lc(shift(@_)); 1675 1676 # Check that the necessary arguments were supplied 1677 if (!$target_language_code) { 1678 &throw_fatal_error("Missing command argument."); 1679 } 1680 1681 # Get (and check) the translation configuration 1682 # my ($source_file_dir, $target_file, $translation_file_type) = &get_translation_configuration($target_language_code, $translation_file_key); 1683 1684 my %source_files_key_to_text_mapping = (); 1685 my %target_files_key_to_text_mapping = (); 1686 my %source_files_key_to_last_update_date_mapping = (); 1687 my %target_files_key_to_last_update_date_mapping = (); 1688 1689 &build_gs3_configuration($target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 1690 1691 &log_message("Total number of source chunks: " . scalar(keys(%source_files_key_to_text_mapping))); 1692 &log_message("Total number of target chunks: " . scalar(keys(%target_files_key_to_text_mapping))); 1693 1694 my $xml_response = &create_xml_response_for_all_chunks($translation_file_key, "", \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 1695 return $xml_response; 1696 } 1697 1698 1699 sub get_first_n_chunks_requiring_work_for_gs3 1700 { 1701 # The code of the target language (ensure it is lowercase) 1702 my $target_language_code = lc(shift(@_)); 1703 # The key of the file to translate (ensure it is lowercase) 1704 my $translation_file_key = lc(shift(@_)); 1705 # The number of chunks to return (defaults to one if not specified) 1706 my $num_chunks_to_return = shift(@_) || "1"; 1707 1708 # Check that the necessary arguments were supplied 1709 if (!$target_language_code || !$translation_file_key) { 1710 &throw_fatal_error("Missing command argument."); 1711 } 1712 1713 my %source_files_key_to_text_mapping = (); 1714 my %target_files_key_to_text_mapping = (); 1715 my %source_files_key_to_last_update_date_mapping = (); 1716 my %target_files_key_to_last_update_date_mapping = (); 1717 1718 &build_gs3_configuration($target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, 1719 \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 1720 1721 # Determine the target file chunks requiring translation 1722 my @target_files_keys_requiring_translation = &determine_chunks_requiring_translation(\%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping); 1723 # Determine the target file chunks requiring updating 1724 my @target_files_keys_requiring_updating = &determine_chunks_requiring_updating(\%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 1725 &log_message("Total number of target chunks requiring translation: " . scalar(@target_files_keys_requiring_translation)); 1726 &log_message("Total number of target chunks requiring updating: " . scalar(@target_files_keys_requiring_updating)); 1727 1728 my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, "", scalar(keys(%source_files_key_to_text_mapping)), 1729 \@target_files_keys_requiring_translation, \@target_files_keys_requiring_updating, 1730 $num_chunks_to_return, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, 1731 \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 1732 1733 return $xml_response; 1734 } 1735 1736 1737 1738 sub build_gs3_configuration 1739 { 1740 my ($target_language_code, $source_files_key_to_text_mapping, $target_files_key_to_text_mapping, 1741 $source_files_key_to_gti_comment_mapping, $target_files_key_to_gti_comment_mapping) = @_; 1742 1743 my $source_file_directory = "greenstone3"; 1744 my $translation_file_type = "resource_bundle"; 1745 1746 foreach my $interface_file_key (@gs3_interface_files) { 1747 1748 &log_message("Greenstone 3 interface file: " . $interface_file_key); 1749 1750 # Parse the source language and target language files 1751 my $source_file = &util::filename_cat($source_file_directory, $interface_file_key.".properties"); 1752 my @source_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $source_file)); 1753 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 1754 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 1755 my %source_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 1756 1757 my $target_file = &util::filename_cat($source_file_directory, $interface_file_key."_".$target_language_code.".properties"); 1758 my @target_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $target_file)); 1759 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type); 1760 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 1761 my %target_file_key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 1762 1763 1764 # Filter out any automatically translated chunks 1765 foreach my $chunk_key (keys(%source_file_key_to_line_mapping)) { 1766 if (&is_chunk_automatically_translated($chunk_key, $translation_file_type)) { 1767 delete $source_file_key_to_line_mapping{$chunk_key}; 1768 delete $target_file_key_to_line_mapping{$chunk_key}; 1769 } 1770 } 1771 1772 &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping))); 1773 &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping))); 1774 1775 foreach my $chunk_key (keys(%source_file_key_to_text_mapping)) { 1776 my $global_chunk_key = "$interface_file_key.$chunk_key"; 1777 $source_files_key_to_text_mapping->{$global_chunk_key} = $source_file_key_to_text_mapping{$chunk_key}; 1778 $source_files_key_to_gti_comment_mapping->{$global_chunk_key} = $source_file_key_to_gti_comment_mapping{$chunk_key}; 1779 1780 if (defined $target_file_key_to_text_mapping{$chunk_key}) { 1781 $target_files_key_to_text_mapping->{$global_chunk_key} = $target_file_key_to_text_mapping{$chunk_key}; 1782 $target_files_key_to_gti_comment_mapping->{$global_chunk_key} = $target_file_key_to_gti_comment_mapping{$chunk_key}; 1783 } 1784 } 1785 } 1786 } 1787 1788 1789 sub write_translated_gs3interface 1790 { 1791 my $source_file_key_to_text_mapping = shift(@_); 1792 my $target_file_key_to_text_mapping = shift(@_); 1793 my $target_file_key_to_gti_comment_mapping = shift(@_); 1794 my $target_language_code = shift(@_); 1795 1796 my @sorted_chunk_keys = sort (keys(%$source_file_key_to_text_mapping)); 1797 1798 my %translated_interface_file_keys = (); 1799 foreach my $chunk_key (keys(%$target_file_key_to_text_mapping)) { 1800 $chunk_key =~ /^([^\.]+)?\.(.*)$/; 1801 if (!defined $translated_interface_file_keys{$1}) { 1802 &log_message("Updated interface file: " . $1); 1803 $translated_interface_file_keys{$1}=""; 1804 } 1805 } 1806 &log_message("Updated interface files: " . scalar(keys(%translated_interface_file_keys))); 1807 1808 my $source_file_directory = "greenstone3"; 1809 1810 foreach my $interface_file_key (keys(%translated_interface_file_keys)) { 1811 1812 # Build a mapping from chunk key to source file line, and from source file line to chunk key 1813 my $source_file = &util::filename_cat($source_file_directory, "$interface_file_key.properties"); 1814 my @source_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $source_file)); 1815 my %source_file_key_to_line_mapping = &build_key_to_line_mapping_for_resource_bundle(@source_file_lines); 1816 my %source_file_line_to_key_mapping = (); 1817 foreach my $chunk_key (keys(%source_file_key_to_line_mapping)) { 1818 $source_file_line_to_key_mapping{$source_file_key_to_line_mapping{$chunk_key}} = $chunk_key; 1819 } 1820 1821 # Write the new target file 1822 my $target_file = &util::filename_cat($source_file_directory, $interface_file_key . "_" . $target_language_code . ".properties"); 1823 my $target_file_path = &util::filename_cat($gsdl_root_directory, $target_file); 1824 if (!open(TARGET_FILE, ">$target_file_path")) { 1825 &throw_fatal_error("Could not write target file $target_file_path."); 1826 } 1827 1828 # Model the new target file on the source file, with the target file translations 1829 my $source_file_line_number = 0; 1830 foreach my $line_key (sort sort_by_line (keys(%source_file_line_to_key_mapping))) { 1831 # Fill in the gaps before this chunk starts 1832 my $source_file_chunk_starting_line_number = (split(/-/, $line_key))[0]; 1833 my $source_file_chunk_finishing_line_number = (split(/-/, $line_key))[1]; 1834 while ($source_file_line_number < $source_file_chunk_starting_line_number) { 1835 print TARGET_FILE $source_file_lines[$source_file_line_number]; 1836 $source_file_line_number++; 1837 } 1838 $source_file_line_number = $source_file_chunk_finishing_line_number + 1; 1839 1840 my $chunk_key = $source_file_line_to_key_mapping{$line_key}; 1841 my $global_chunk_key = "$interface_file_key.$chunk_key"; 1842 my $source_file_chunk_text = $source_file_key_to_text_mapping->{$global_chunk_key}; 1843 my $target_file_chunk_text = $target_file_key_to_text_mapping->{$global_chunk_key} || ""; 1844 1845 # If no translation exists for this chunk, show this, and move on 1846 if ($source_file_chunk_text ne "" && $target_file_chunk_text eq "") { 1847 print TARGET_FILE "# -- Missing translation: $chunk_key\n"; 1848 next; 1849 } 1850 1851 print TARGET_FILE "$chunk_key:$target_file_chunk_text"; 1852 if ($target_file_key_to_gti_comment_mapping->{$global_chunk_key}) { 1853 print TARGET_FILE " # " . $target_file_key_to_gti_comment_mapping->{$global_chunk_key}; 1854 } 1855 print TARGET_FILE "\n"; 1856 } 1857 1858 close(TARGET_FILE); 1859 } 1860 } 1861 1512 1862 &main(@ARGV); -
gsdl/trunk/macros/english2.dm
r18055 r18460 1096 1096 _textgtitutorials_ {Tutorial Exercises} 1097 1097 _textgtigreenorg_ {Greenstone.org} 1098 _textgtigs3 core_ {Greenstone3 Interface (Default)}1098 _textgtigs3interface_ {Greenstone3 Interface} 1099 1099 1100 1100 #for greenstone manuals … … 1137 1137 1138 1138 <ol> 1139 <li>Download <a href="_gwcgi_?a=gti&p=excel&e=_compressedoptions_">this file</a>.1139 <li>Download either <a href="_gwcgi_?a=gti&p=excel&tct=work&e=_compressedoptions_">this file</a> for all the remaining work, or <a href="_gwcgi_?a=gti&p=excel&tct=all&e=_compressedoptions_">this file</a> for all the strings in this module. 1140 1140 <li>Open the downloaded file in Microsoft Excel (Office 2003/XP or more recent versions is required) and save as Microsoft Excel workbook (.xls) format. 1141 1141 <li>Enter the translations in the boxes provided. -
gsdl/trunk/macros/gti.dm
r18430 r18460 179 179 <a href="_gwcgi_?a=gti&p=find&e=_compressedoptions_">_textgticorrectexistingtranslations_</a><br> 180 180 _If_(_4_ eq _gtidownloadglihelp, <a href="_4_">, <a href="_httpprefix_/_4_">)_textgtidownloadtargetfile_</a> 181 _If_(_gtiglihelpzipfilepath_ eq "disabled", <a href="_gwcgi_?a=gti&p=glihelp&e=_compressedoptions_">_textgtiglihelpzipfile_</a>, <a href="_httpprefix_/_gtiglihelpzipfilepath_">_gtiglihelpzipfilepath_ Reday to download</a>)<br> 181 182 _If_(_gtiglihelpzipfilepath_, <a href="_httpprefix_/_gtiglihelpzipfilepath_">_textgtiglihelpzipfile_</a>,)<br> 183 182 184 <a href="_gwcgi_?a=gti&p=offline&e=_compressedoptions_">_textgtitranslatefileoffline_</a><br> 183 185 _gtiviewtranslationfileinaction_ … … 186 188 } 187 189 188 _gtiglihelpzipfilepath_ { disabled}189 190 _textgtiglihelpzipfile_ { Download the zipped GLI Help operational files}190 _gtiglihelpzipfilepath_ {} 191 192 _textgtiglihelpzipfile_ {Clicke here to download the operational files for GLI Help} 191 193 192 194 # -------------------------------------------------------------------------------- -
gsdl/trunk/runtime-src/src/recpt/gtiaction.cpp
r17545 r18460 192 192 193 193 // Define the page content for the GTI view status page 194 195 196 197 194 if (args["p"] == "status") { 195 define_gti_status_page(disp, args, logout); 196 return; 197 } 198 198 199 199 // Process user translations 200 200 if (args["p"] == "submit") { 201 201 process_gti_submissions(disp, args, logout, true); 202 } 203 204 if (args["p"] == "glihelp") { 205 produce_glihelp_zipfile(disp, args, logout); 202 206 } 203 207 … … 335 339 336 340 337 341 //lang_status_temp += "<td valign=\"top\" nowrap>_gtitranslationfilestatus2_(" + num_chunks_translated + "," + num_chunks_requiring_translation + "," + num_chunks_requiring_updating + ")</td>"; 338 342 339 340 343 // List the file names as the first row of the status table 344 // Add up number of strings need to be translate in each file, as the second line of the status table 341 345 if (first_lang) { 342 346 files_temp += "<th class=\"status\">_textgti" + translation_file_key + "_</th>\n"; … … 484 488 languageinfo_tmap loaded_languages = recpt->get_configinfo().languages; 485 489 disp.setmacro("gtitargetlanguagename", "gti", loaded_languages[target_language_code].longname); 486 disp.setmacro("gtitargetfilepath", "gti", gti_response.translation_files_key_to_target_file_path_mapping[translation_file_key]); 490 if (translation_file_key == "glihelp") { 491 disp.setmacro("gtitargetfilepath", "gti", "_gtidownloadglihelp_"); 492 } else { 493 disp.setmacro("gtitargetfilepath", "gti", gti_response.translation_files_key_to_target_file_path_mapping[translation_file_key]); 494 } 487 495 disp.setmacro("gtitranslationfiledesc", "gti", "_gti:textgti" + translation_file_key + "_"); 488 496 disp.setmacro("gtiviewtranslationfileinaction", "gti", "_gti:gtiview" + translation_file_key + "inaction_"); … … 618 626 text_t target_language_code = args["tlc"]; 619 627 text_t translation_file_key = args["tfk"]; 628 text_t target_chunk_type = args["tct"]; 620 629 621 630 // Send a request to gti.pl to get the Excel spreadsheet data 622 text_t gti_arguments = "get-first-n-chunks-requiring-work " + target_language_code + " " + translation_file_key + " " + "10000" + " | java -cp /home/nzdl/gti ApplyXSLT /home/nzdl/gti/gti-generate-excel-xml.xsl -"; 623 text_t gti_response_xml_text = do_gti_request(gti_arguments, logout); 631 text_t gti_arguments = ""; 632 if (target_chunk_type == "work") { 633 gti_arguments = "get-first-n-chunks-requiring-work " + target_language_code + " " + translation_file_key + " " + "10000" + " | /opt/jdk1.6.0/bin/java -cp /home/nzdl/gti:/home/nzdl/gti/xalan.jar ApplyXSLT /home/nzdl/gti/gti-generate-excel-xml.xsl -"; 634 } else { 635 gti_arguments = "get-all-chunks " + target_language_code + " " + translation_file_key + " | /opt/jdk1.6.0/bin/java -cp /home/nzdl/gti:/home/nzdl/gti/xalan.jar ApplyXSLT /home/nzdl/gti/gti-generate-excel-xml.xsl -"; 636 } 637 638 text_t gti_response_xml_text = do_gti_request(gti_arguments, logout); 624 639 if (gti_response_xml_text == "") { 625 640 // An error has occurred … … 635 650 } 636 651 652 bool gtiaction::produce_glihelp_zipfile(displayclass& disp, cgiargsclass& args, ostream& logout) 653 { 654 text_t target_language_code = args["tlc"]; 655 text_t gti_arguments = "create-glihelp-zip-file " + target_language_code; 656 657 do_gti_request(gti_arguments, logout); 658 659 disp.setmacro("gtiglihelpzipfilepath", "gti", target_language_code + "_GLIHelp.zip"); 660 661 return true; 662 } 637 663 638 664 -
gsdl/trunk/runtime-src/src/recpt/gtiaction.h
r17545 r18460 118 118 119 119 bool produce_excel_spreadsheet(cgiargsclass& args, ostream& logout); 120 121 bool produce_glihelp_zipfile(displayclass& disp, cgiargsclass& args, ostream& logout); 120 122 }; 121 123
Note:
See TracChangeset
for help on using the changeset viewer.