Changeset 12483
- Timestamp:
- 2006-08-18T16:37:21+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/gti.pl
r12481 r12483 426 426 my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type); 427 427 my %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type); 428 my %source_file_key_to_ comment_date_mapping = &build_key_to_comment_date_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type);428 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); 429 429 &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping))); 430 430 … … 432 432 my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type); 433 433 my %target_file_key_to_text_mapping = &build_key_to_text_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type); 434 my %target_file_key_to_ comment_date_mapping = &build_key_to_comment_date_mapping(\@target_file_lines, \%target_file_key_to_line_mapping, $translation_file_type);434 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); 435 435 &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping))); 436 436 … … 524 524 if ($force_submission_flag || $target_file_key_to_submission_mapping{$chunk_key} ne $target_file_key_to_text_mapping{$chunk_key}) { 525 525 $target_file_key_to_text_mapping{$chunk_key} = $target_file_key_to_submission_mapping{$chunk_key}; 526 $target_file_key_to_ comment_date_mapping{$chunk_key} = $submission_date;527 } 528 } 529 530 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_ comment_date_mapping, \$target_language_code)";526 $target_file_key_to_gti_comment_mapping{$chunk_key} = "Updated $submission_date"; 527 } 528 } 529 530 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)"; 531 531 } 532 532 … … 666 666 667 667 # Build a mapping from key to comment date 668 my %key_to_ comment_date_mapping = &build_key_to_comment_date_mapping($file_lines, $key_to_line_mapping, $translation_file_type);668 my %key_to_gti_comment_mapping = &build_key_to_gti_comment_mapping($file_lines, $key_to_line_mapping, $translation_file_type); 669 669 670 670 # Build a mapping from key to last update date (the latter of the CVS date and comment date) … … 676 676 677 677 # If a comment date exists and it is after the CVS date, use that instead 678 my $chunk_comment_date = $key_to_comment_date_mapping{$chunk_key}; 679 if (defined($chunk_comment_date) && (!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date))) { 680 $key_to_last_update_date_mapping{$chunk_key} = $chunk_comment_date; 678 my $chunk_gti_comment = $key_to_gti_comment_mapping{$chunk_key}; 679 if (defined($chunk_gti_comment) && $chunk_gti_comment =~ /(\d?\d-\D\D\D-\d\d\d\d)/) { 680 my $chunk_comment_date = $1; 681 if ((!defined($chunk_cvs_date) || &is_date_after($chunk_comment_date, $chunk_cvs_date))) { 682 $key_to_last_update_date_mapping{$chunk_key} = $chunk_comment_date; 683 } 681 684 } 682 685 } … … 727 730 728 731 729 sub build_key_to_ comment_date_mapping732 sub build_key_to_gti_comment_mapping 730 733 { 731 734 my ($file_lines, $key_to_line_mapping, $translation_file_type) = @_; 732 735 733 my %key_to_ comment_date_mapping = ();736 my %key_to_gti_comment_mapping = (); 734 737 foreach my $chunk_key (keys(%$key_to_line_mapping)) { 735 738 my $chunk_starting_line = (split(/-/, $key_to_line_mapping->{$chunk_key}))[0]; … … 741 744 } 742 745 743 # Map from chunk key to comment date744 my $chunk_ comment_date;745 eval "\$chunk_ comment_date = &get_${translation_file_type}_chunk_comment_date(\$chunk_text)";746 $key_to_ comment_date_mapping{$chunk_key} = $chunk_comment_date if (defined($chunk_comment_date));747 } 748 749 return %key_to_ comment_date_mapping;746 # Map from chunk key to GTI comment 747 my $chunk_gti_comment; 748 eval "\$chunk_gti_comment = &get_${translation_file_type}_chunk_gti_comment(\$chunk_text)"; 749 $key_to_gti_comment_mapping{$chunk_key} = $chunk_gti_comment if (defined($chunk_gti_comment)); 750 } 751 752 return %key_to_gti_comment_mapping; 750 753 } 751 754 … … 946 949 947 950 948 sub get_macrofile_chunk_ comment_date951 sub get_macrofile_chunk_gti_comment 949 952 { 950 953 my ($chunk_text) = @_; 951 954 952 955 # Check for an "Updated DD-MMM-YYYY" comment at the end of the chunk 953 if ($chunk_text =~ /\#\s+ Updated\s+(\d?\d-\D\D\D-\d\d\d\d)\s*$/i) {956 if ($chunk_text =~ /\#\s+(Updated\s+\d?\d-\D\D\D-\d\d\d\d)\s*$/i) { 954 957 return $1; 955 958 } … … 981 984 my @target_file_lines = @{shift(@_)}; 982 985 my $target_file_key_to_text_mapping = shift(@_); 983 my $target_file_key_to_ comment_date_mapping = shift(@_);986 my $target_file_key_to_gti_comment_mapping = shift(@_); 984 987 my $target_language_code = shift(@_); 985 988 … … 1069 1072 } 1070 1073 1071 # Add the update date, if one exists1072 if ($target_file_key_to_ comment_date_mapping->{$chunk_key}) {1073 print TARGET_FILE " # Updated " . $target_file_key_to_comment_date_mapping->{$chunk_key};1074 # Add the "updated" comment, if one exists 1075 if ($target_file_key_to_gti_comment_mapping->{$chunk_key}) { 1076 print TARGET_FILE " # " . $target_file_key_to_gti_comment_mapping->{$chunk_key}; 1074 1077 } 1075 1078 print TARGET_FILE "\n"; … … 1124 1127 1125 1128 1126 sub get_resource_bundle_chunk_ comment_date1129 sub get_resource_bundle_chunk_gti_comment 1127 1130 { 1128 1131 my ($chunk_text) = @_; 1129 1132 1130 1133 # Check for an "Updated DD-MMM-YYYY" comment at the end of the chunk 1131 if ($chunk_text =~ /\#\s+ Updated\s+(\d?\d-\D\D\D-\d\d\d\d)\s*$/i) {1134 if ($chunk_text =~ /\#\s+(Updated\s+\d?\d-\D\D\D-\d\d\d\d)\s*$/i) { 1132 1135 return $1; 1133 1136 } … … 1152 1155 my @target_file_lines = @{shift(@_)}; # Not used 1153 1156 my $target_file_key_to_text_mapping = shift(@_); 1154 my $target_file_key_to_ comment_date_mapping = shift(@_);1157 my $target_file_key_to_gti_comment_mapping = shift(@_); 1155 1158 my $target_language_code = shift(@_); # Not used 1156 1159 … … 1191 1194 1192 1195 print TARGET_FILE "$chunk_key:$target_file_chunk_text"; 1193 if ($target_file_key_to_ comment_date_mapping->{$chunk_key}) {1194 print TARGET_FILE " # Updated " . $target_file_key_to_comment_date_mapping->{$chunk_key};1196 if ($target_file_key_to_gti_comment_mapping->{$chunk_key}) { 1197 print TARGET_FILE " # " . $target_file_key_to_gti_comment_mapping->{$chunk_key}; 1195 1198 } 1196 1199 print TARGET_FILE "\n"; … … 1258 1261 1259 1262 1260 sub get_greenstone_xml_chunk_ comment_date1263 sub get_greenstone_xml_chunk_gti_comment 1261 1264 { 1262 1265 my ($chunk_text) = @_; … … 1286 1289 my @target_file_lines = @{shift(@_)}; # Not used 1287 1290 my $target_file_key_to_text_mapping = shift(@_); 1288 my $target_file_key_to_ comment_date_mapping = shift(@_);1291 my $target_file_key_to_gti_comment_mapping = shift(@_); 1289 1292 my $target_language_code = shift(@_); # Not used 1290 1293 … … 1326 1329 1327 1330 print TARGET_FILE "<Text id=\"$chunk_key\">$target_file_chunk_text</Text>"; 1328 if ($target_file_key_to_ comment_date_mapping->{$chunk_key}) {1329 print TARGET_FILE "<Updated date=\"" . $target_file_key_to_ comment_date_mapping->{$chunk_key} . "\"\/>";1331 if ($target_file_key_to_gti_comment_mapping->{$chunk_key}) { 1332 print TARGET_FILE "<Updated date=\"" . $target_file_key_to_gti_comment_mapping->{$chunk_key} . "\"\/>"; 1330 1333 } 1331 1334 print TARGET_FILE "\n";
Note:
See TracChangeset
for help on using the changeset viewer.