Changeset 12483


Ignore:
Timestamp:
2006-08-18T16:37:21+12:00 (18 years ago)
Author:
mdewsnip
Message:

Changed the way the Updated comments are dealt with, in preparation for recording who made the change as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gti.pl

    r12481 r12483  
    426426    my %source_file_key_to_line_mapping = &build_key_to_line_mapping(\@source_file_lines, $translation_file_type);
    427427    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);
    429429    &log_message("Number of source chunks: " . scalar(keys(%source_file_key_to_text_mapping)));
    430430
     
    432432    my %target_file_key_to_line_mapping = &build_key_to_line_mapping(\@target_file_lines, $translation_file_type);
    433433    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);
    435435    &log_message("Number of target chunks: " . scalar(keys(%target_file_key_to_text_mapping)));
    436436
     
    524524    if ($force_submission_flag || $target_file_key_to_submission_mapping{$chunk_key} ne $target_file_key_to_text_mapping{$chunk_key}) {
    525525        $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)";
    531531}
    532532
     
    666666
    667667    # 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);
    669669
    670670    # Build a mapping from key to last update date (the latter of the CVS date and comment date)
     
    676676
    677677    # 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        }
    681684    }
    682685    }
     
    727730
    728731
    729 sub build_key_to_comment_date_mapping
     732sub build_key_to_gti_comment_mapping
    730733{
    731734    my ($file_lines, $key_to_line_mapping, $translation_file_type) = @_;
    732735
    733     my %key_to_comment_date_mapping = ();
     736    my %key_to_gti_comment_mapping = ();
    734737    foreach my $chunk_key (keys(%$key_to_line_mapping)) {
    735738    my $chunk_starting_line = (split(/-/, $key_to_line_mapping->{$chunk_key}))[0];
     
    741744    }
    742745
    743     # Map from chunk key to comment date
    744     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;
    750753}
    751754
     
    946949
    947950
    948 sub get_macrofile_chunk_comment_date
     951sub get_macrofile_chunk_gti_comment
    949952{
    950953    my ($chunk_text) = @_;
    951954
    952955    # 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) {
    954957    return $1;
    955958    }
     
    981984    my @target_file_lines = @{shift(@_)};
    982985    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(@_);
    984987    my $target_language_code = shift(@_);
    985988
     
    10691072    }
    10701073
    1071     # Add the update date, if one exists
    1072     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};
    10741077    }
    10751078    print TARGET_FILE "\n";
     
    11241127
    11251128
    1126 sub get_resource_bundle_chunk_comment_date
     1129sub get_resource_bundle_chunk_gti_comment
    11271130{
    11281131    my ($chunk_text) = @_;
    11291132
    11301133    # 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) {
    11321135    return $1;
    11331136    }
     
    11521155    my @target_file_lines = @{shift(@_)};  # Not used
    11531156    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(@_);
    11551158    my $target_language_code = shift(@_);  # Not used
    11561159
     
    11911194
    11921195    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};
    11951198    }
    11961199    print TARGET_FILE "\n";
     
    12581261
    12591262
    1260 sub get_greenstone_xml_chunk_comment_date
     1263sub get_greenstone_xml_chunk_gti_comment
    12611264{
    12621265    my ($chunk_text) = @_;
     
    12861289    my @target_file_lines = @{shift(@_)};  # Not used
    12871290    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(@_);
    12891292    my $target_language_code = shift(@_);  # Not used
    12901293
     
    13261329
    13271330    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} . "\"\/>";
    13301333    }
    13311334    print TARGET_FILE "\n";
Note: See TracChangeset for help on using the changeset viewer.