Changeset 29456


Ignore:
Timestamp:
11/20/14 19:01:20 (6 years ago)
Author:
ak19
Message:

Now processes multi-line properties in properties files (resource bundles). Discovered the need for this change when testing submissions for GS3 translations, otherwise all except the first line of any property in an English GS3 prop file, ends up in the matching language property file after the submission step.

File:
1 edited

Legend:

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

    r29415 r29456  
    15791579#   RESOURCE BUNDLE FUNCTIONS
    15801580
     1581# need to handle multi-line properties. A multiline ends on \ if it continues over the next line
    15811582sub build_key_to_line_mapping_for_resource_bundle
    15821583{
     
    15841585   
    15851586    my %chunk_key_to_line_mapping = ();
     1587
     1588    my $chunk_key;
     1589    my $startindex = -1;
     1590
    15861591    for (my $i = 0; $i < scalar(@file_lines); $i++) {
    15871592        my $line = $file_lines[$i];
     
    15901595        # Line contains a dictionary string
    15911596        if ($line =~ /^(\S+?)[:|=](.*)$/) {
    1592             my $chunk_key = $1;
    1593            
     1597            $chunk_key = $1;
     1598            $startindex = $i;
     1599        }       
     1600        if ($startindex != -1) {
     1601            if($line !~ m/\\$/) { # line finished
     1602            # $i keeps track of the line at which this property (chunk_key) finishes
     1603
    15941604            # Map from chunk key to line
    1595             $chunk_key_to_line_mapping{$chunk_key} = $i . "-" . $i;
    1596         }
     1605            $chunk_key_to_line_mapping{$chunk_key} = $startindex . "-" . $i;
     1606            $startindex = -1;
     1607            $chunk_key = "";
     1608            }
     1609        }               
    15971610    }
    15981611   
     
    16061619   
    16071620    # Simple: just remove string key
    1608     $chunk_text =~ s/^(\S+?)[:|=](\s*)//;
    1609     $chunk_text =~ s/(\s*)$//;  # Remove any nasty whitespace, carriage returns etc.
    1610     $chunk_text =~ s/(\s*)\#\s+Updated\s+(\d?\d-\D\D\D-\d\d\d\d.*)\s*$//i;
     1621    $chunk_text =~ s/^(\S+?)[:|=](\s*)//s;
     1622    $chunk_text =~ s/(\s*)$//s;  # Remove any nasty whitespace, carriage returns etc.
     1623    $chunk_text =~ s/(\s*)\#\s+Updated\s+(\d?\d-\D\D\D-\d\d\d\d.*)\s*$//is;
    16111624   
    16121625    return $chunk_text;
     
    20492062                $target_files_key_to_gti_comment_mapping->{$global_chunk_key} = $target_file_key_to_gti_comment_mapping{$chunk_key};
    20502063            }
    2051         }   
     2064        }
    20522065    }
    20532066}
Note: See TracChangeset for help on using the changeset viewer.