Changeset 30687
- Timestamp:
- 2016-08-05T20:43:47+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/bin/script/gti.pl
r30681 r30687 678 678 # Check that the translations are valid 679 679 foreach my $chunk_key (keys(%source_file_key_to_submission_mapping)) { 680 681 # Kathy introduced escaped colons ("\:") into chunk keys in properties files (greenstone3/metadata_names), 682 # but they're not escaped in the submitted XML versions. So have to carefully compare for submissions: 683 my $escaped_chunk_key = $chunk_key; 684 $escaped_chunk_key =~ s/:/\\:/g; 685 680 686 # Make sure the submitted chunk still exists in the source file 681 if (!defined($source_file_key_to_text_mapping{$ chunk_key})) {687 if (!defined($source_file_key_to_text_mapping{$escaped_chunk_key})) { 682 688 &log_message("Warning: Source chunk $chunk_key no longer exists (ignoring submission)."); 683 689 delete $source_file_key_to_submission_mapping{$chunk_key}; … … 687 693 688 694 # Make sure the submitted source chunk matches the source file chunk 689 if ($source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$ chunk_key})) {695 if ($source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$escaped_chunk_key})) { 690 696 #if (&unmake_text_xml_safe($source_file_key_to_submission_mapping{$chunk_key}) ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key})) { 691 697 #print STDERR "**** $source_file_key_to_submission_mapping{$chunk_key}\n"; 692 698 #print STDERR "**** " . &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}) ."\n"; 693 699 694 &log_message("Warning: Source chunk $ chunk_key has changed (ignoring submission).");695 &log_message("Submission source: $source_file_key_to_submission_mapping{$chunk_key}");696 &log_message(" Source text: $source_file_key_to_text_mapping{$chunk_key}");700 &log_message("Warning: Source chunk $escaped_chunk_key has changed (ignoring submission)."); 701 &log_message("Submission source: |$source_file_key_to_submission_mapping{$chunk_key}|"); 702 &log_message(" Source text: |$source_file_key_to_text_mapping{$escaped_chunk_key}|"); 697 703 delete $source_file_key_to_submission_mapping{$chunk_key}; 698 704 delete $target_file_key_to_submission_mapping{$chunk_key}; … … 704 710 foreach my $chunk_key (keys(%target_file_key_to_submission_mapping)) { 705 711 # Only apply the submission if it is a change, unless -force_submission has been specified 706 if ($force_submission_flag || !defined($target_file_key_to_text_mapping{$chunk_key}) || $target_file_key_to_submission_mapping{$chunk_key} ne $target_file_key_to_text_mapping{$chunk_key}) { 707 $target_file_key_to_text_mapping{$chunk_key} = $target_file_key_to_submission_mapping{$chunk_key}; 708 $target_file_key_to_gti_comment_mapping{$chunk_key} = "Updated $submission_date by $submitter_username"; 712 my $escaped_chunk_key = $chunk_key; 713 $escaped_chunk_key =~ s/:/\\:/g; 714 if ($force_submission_flag || !defined($target_file_key_to_text_mapping{$escaped_chunk_key}) || $target_file_key_to_submission_mapping{$chunk_key} ne $target_file_key_to_text_mapping{$escaped_chunk_key}) { 715 $target_file_key_to_text_mapping{$escaped_chunk_key} = $target_file_key_to_submission_mapping{$chunk_key}; 716 $target_file_key_to_gti_comment_mapping{$escaped_chunk_key} = "Updated $submission_date by $submitter_username"; 709 717 } 710 718 } … … 917 925 { 918 926 my ($file_lines, $key_to_line_mapping, $translation_file_type) = @_; 919 920 &log_message("@@@ HELLO WORLD");921 922 927 923 928 my %key_to_text_mapping = (); … … 1616 1621 $line =~ s/(\s*)$//; # Remove any nasty whitespace, carriage returns etc. 1617 1622 1623 $line =~ s/\\:/ESCAPEDCOLONTEMP/g; # an escaped colon "\:" should only occur in the chunk_key portion of the line 1624 1618 1625 # Line contains a dictionary string 1619 if ($line =~ /^(\S+ )[:|=](.*)$/) {1626 if ($line =~ /^(\S+?)[:|=](.*)$/) { 1620 1627 $chunk_key = $1; 1628 1629 # an escaped colon "\:" should only occur in the chunk_key portion of the line, put it back in, escaped as before 1630 if($chunk_key =~ m/ESCAPEDCOLONTEMP/) { 1631 $chunk_key =~ s/ESCAPEDCOLONTEMP/\\:/g; 1632 } 1633 1621 1634 $startindex = $i; 1622 1635 } … … 1630 1643 $chunk_key = ""; 1631 1644 } 1632 } 1645 } 1633 1646 } 1634 1647 … … 1641 1654 my ($chunk_text) = @_; 1642 1655 1643 # Simple: just remove string key 1644 $chunk_text =~ s/^(\S+)[:|=](\s*)//s; 1656 $chunk_text =~ s/\\:/ESCAPEDCOLONTEMP/g; # an escaped colon "\:" should only occur in the chunk_key portion of the line 1657 1658 # Simple: just remove string key 1659 $chunk_text =~ s/^(\S+?)[:|=](\s*)//s; 1645 1660 $chunk_text =~ s/(\s*)$//s; # Remove any nasty whitespace, carriage returns etc. 1646 1661 $chunk_text =~ s/(\s*)\#\s+Updated\s+(\d?\d-\D\D\D-\d\d\d\d.*)\s*$//is;
Note:
See TracChangeset
for help on using the changeset viewer.