Changeset 33436


Ignore:
Timestamp:
2019-08-23T23:21:17+12:00 (5 years ago)
Author:
ak19
Message:

3 important changes for 2 separate bugfixes where one bugfix is experimental and additional commented out debug statements. The first bug was when every source string for glihelp was marked as modified and translations wouldn't go through. Code fixed to cope with newlines/general whitespace introduced to the end of the English source strings in xml translation modules (gli help.xml files) and to trim whitespace at the start as well. The second bug is related to commits 28503 and 28518, which made improvements for special cases of processing translations that had to be rolled back because they adversely affected the general case. The bug this time is that in some cases, we don't want to care the unmake_xml_safe version of the original source string with the submission source string, but just compare the plain version of both to detect if the source string has been modified. Any modification to the source string and its translation won't go through. But in some special cases there's no actual change detectible except when the original source string has unmake_xml_safe applied to it in the comparison. This bugfix is a trial and error thing, in that only future cases of processing spreadsheets will tell us if the fix can stay or has to be removed if it too negatively affects the general functioning of processing spreadsheets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/gti.pl

    r32517 r33436  
    594594        ($source_file, $target_file, $translation_file_type)
    595595        = &get_translation_configuration($target_language_code, $translation_file_key);
     596
     597        #&log_message("********************** START SOURCE ***********************************");
    596598       
    597599        # Parse the source language and target language files
     
    600602        %source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type);
    601603        %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);   
     604
     605        #&log_message("********************** START TARGET ***********************************");
    602606       
    603607        @target_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $target_file));
     
    626630    # &log_message("Submission:");
    627631    foreach my $submission_line (@submission_lines) {
    628         $submission_line =~ s/\r$//;
     632    $submission_line =~ s/\r$//;
     633    $submission_line =~ s/ +$//;
    629634        #&log_message("  $submission_line");
    630635    }
     
    647652            $source_file_chunk_text = &unmake_text_xml_safe($source_file_chunk_text);
    648653           
    649             #&log_message("Source file key: $chunk_key");
    650             #&log_message("Source file text: $source_file_chunk_text");
     654            #&log_message("Source file key: |$chunk_key|");
     655            #&log_message("Source file text: |$source_file_chunk_text|");
    651656            $source_file_key_to_submission_mapping{$chunk_key} = $source_file_chunk_text;
    652657        }
     
    666671            $target_file_chunk_text = &unmake_text_xml_safe($target_file_chunk_text);
    667672           
    668             #&log_message("Target file key: $chunk_key");
    669             #&log_message("Target file text: $target_file_chunk_text");
     673            #&log_message("Target file key: |$chunk_key|");
     674            #&log_message("Target file text: |$target_file_chunk_text|");
    670675            $target_file_key_to_submission_mapping{$chunk_key} = $target_file_chunk_text;
    671676        }
     
    691696       
    692697        # Make sure the submitted source chunk matches the source file chunk
    693         if ($source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key})) {
     698        if ($source_file_key_to_submission_mapping{$chunk_key} ne $source_file_key_to_text_mapping{$chunk_key}
     699            && $source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key})) {
    694700        #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})) {
    695                     #print STDERR "**** $source_file_key_to_submission_mapping{$chunk_key}\n";
    696                 #print STDERR "**** " . &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}) ."\n";
     701                    #&log_message("**** submission source:\n|$source_file_key_to_submission_mapping{$chunk_key}|\n");
     702                #&log_message("**** unmake xml safe source:\n|" . &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}) ."|\n");
    697703
    698704            &log_message("Warning: Source chunk $chunk_key has changed (ignoring submission).");
     
    939945        eval "\$key_to_text_mapping{\${chunk_key}} = &import_chunk_from_${translation_file_type}(\$chunk_text)";
    940946
     947        #&log_message("@@@ chunk key: $chunk_key");
     948        #&log_message("@@@ source string: |" . $key_to_text_mapping{$chunk_key} . "|");
     949       
     950       
    941951        #if($chunk_key =~ m/document\\/) {
    942952            #&log_message("Submission source: $source_file_key_to_submission_mapping{$chunk_key}");
     
    16201630        my $line = $file_lines[$i];
    16211631        $line =~ s/(\s*)$//;  # Remove any nasty whitespace, carriage returns etc.
     1632        #&log_message("Got line: ".$line);
    16221633       
    16231634        # a property line has a colon/equals sign as separator that is NOT escaped with a backslash (both keys and values
     
    17651776        my $line = $file_lines[$i];
    17661777        $line =~ s/(\s*)$//;  # Remove any nasty whitespace, carriage returns etc.
    1767        
     1778        #&log_message("Got line: ".$line); 
    17681779        # Line contains a string to translate
    17691780        if ($line =~ /^\s*<Text id=\"(.*?)\">/) {
     
    17741785            # While there is still text of the string to go...
    17751786            my $startline = $i;
    1776             while ($line !~ /<\/Text>$/) {
     1787            while ($line !~ /<\/Text>\s*$/) {
    17771788                $i++;
    17781789                if ($i == scalar(@file_lines)) {
     
    17831794                $line =~ s/<Updated date=\"\d?\d-\D\D\D-\d\d\d\d.*\"\/>$//;
    17841795            }
    1785            
     1796            #&log_message("@@@ Line is now: ".$line);
    17861797            # Map from chunk key to line
    17871798            if (!defined($chunk_key_to_line_mapping{$chunk_key})) {
     
    18051816    $chunk_text =~ s/^\s*<Text id=\"(.*?)\">(\s*)//;
    18061817    $chunk_text =~ s/<Updated date=\"\d?\d-\D\D\D-\d\d\d\d.*\"\/>$//;
    1807     $chunk_text =~ s/<\/Text>$//;
     1818    $chunk_text =~ s/\s*<\/Text>\s*$//;
    18081819   
    18091820    return $chunk_text;
Note: See TracChangeset for help on using the changeset viewer.