Changeset 30581

Show
Ignore:
Timestamp:
17.06.2016 19:59:44 (3 years ago)
Author:
ak19
Message:

GTI related changes to add gs3 demo collection config files' displayitems for translation.

Files:
3 modified

Legend:

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

    r30562 r30581  
    103103        'source_file' => "greenstone3", 
    104104        'target_file' => "greenstone3" 
     105}, 
     106 
     107# collection config display items of GS3 demo collections. Checked out as gs3-collection-configs 
     108# from http://svn.greenstone.org/main/trunk/gs3-collection-configs 
     109{ 'key' => "gs3colcfg", 
     110    'file_type' => "resource_bundle", 
     111    'source_file' => "gs3-collection-configs", 
     112    'target_file' => "gs3-collection-configs" 
    105113} 
    106114]; 
     115 
     116my @gs3_col_cfg_files = ("lucene-jdbm-demo", "solr-jdbm-demo"); 
    107117 
    108118my @gs3_interface_files = ("interface_default", "ServiceRack", "metadata_names"); 
     
    148158    if ($gti_command =~ /^get-all-chunks$/i) { 
    149159        # Check that GS3 interface is the target 
    150         if ($module eq "gs3interface") { 
     160        if ($module eq "gs3interface" || $module eq "gs3colcfg") { 
    151161            print &get_all_chunks_for_gs3(@gti_command_arguments); 
    152162        } else { 
     
    155165    } 
    156166    elsif ($gti_command =~ /^get-first-n-chunks-requiring-work$/i) { 
    157         if ($module eq "gs3interface") {        
     167        if ($module eq "gs3interface" || $module eq "gs3colcfg") {      
    158168            print &get_first_n_chunks_requiring_work_for_gs3(@gti_command_arguments); 
    159169        } else { 
     
    162172    } 
    163173    elsif ($gti_command =~ /^get-uptodate-chunks$/i) { 
    164         if ($module eq "gs3interface") {        
     174        if ($module eq "gs3interface" || $module eq "gs3colcfg") {      
    165175            print &get_uptodate_chunks_for_gs3(@gti_command_arguments); 
    166176        } else { 
     
    397407        my $target_file_name = ""; 
    398408         
    399         if ($translation_file->{'key'} eq "gs3interface") { 
     409        if ($translation_file->{'key'} eq "gs3interface" || $translation_file->{'key'} eq "gs3colcfg") { 
    400410            my (%source_file_key_to_text_mapping, %target_file_key_to_text_mapping, %source_file_key_to_last_update_date_mapping, %target_file_key_to_last_update_date_mapping ) = (); 
    401             &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, \%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping );     
     411            &build_gs3_configuration($translation_file->{'key'}, $target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, \%source_file_key_to_last_update_date_mapping, \%target_file_key_to_last_update_date_mapping );     
    402412             
    403413            my @target_file_keys_requiring_translation = &determine_chunks_requiring_translation(\%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping);      
     
    491501     
    492502     
    493     if ($translation_file_key ne "gs3interface") { 
     503    if ($translation_file_key ne "gs3interface" && $translation_file_key ne "gs3colcfg") { 
    494504        # Get (and check) the translation configuration 
    495505        ($source_file, $target_file, $translation_file_type) = &get_translation_configuration($target_language_code, $translation_file_key); 
     
    518528        # Not needed in this case 
    519529        my (%source_file_key_to_gti_command_mapping, %target_file_key_to_gti_command_mapping) = (); 
    520         &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, 
     530        &build_gs3_configuration($translation_file_key, $target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping, 
    521531        \%source_file_key_to_gti_command_mapping, \%target_file_key_to_gti_command_mapping, 1); 
    522532    } 
     
    580590     
    581591     
    582     if ($translation_file_key ne "gs3interface") { 
     592    if ($translation_file_key ne "gs3interface" && $translation_file_key ne "gs3colcfg") { 
    583593        # Get (and check) the translation configuration 
    584594        ($source_file, $target_file, $translation_file_type) 
     
    597607    }  
    598608    else { 
    599         &build_gs3_configuration($target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping,  
     609        &build_gs3_configuration($translation_file_key, $target_language_code, \%source_file_key_to_text_mapping, \%target_file_key_to_text_mapping,  
    600610        \%source_file_key_to_gti_comment_mapping, \%target_file_key_to_gti_comment_mapping, 1); 
    601611    } 
     
    700710    } 
    701711     
    702     if ($translation_file_key ne "gs3interface") { 
     712    if ($translation_file_key ne "gs3interface" && $translation_file_key ne "gs3colcfg") { 
    703713        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)"; 
    704714    } else { 
    705         eval "&write_translated_gs3interface(\\\%source_file_key_to_text_mapping, \\\%target_file_key_to_text_mapping, \\\%target_file_key_to_gti_comment_mapping, \$target_language_code)"; 
     715        eval "&write_translated_gs3interface(\$translation_file_key, \\\%source_file_key_to_text_mapping, \\\%target_file_key_to_text_mapping, \\\%target_file_key_to_gti_comment_mapping, \$target_language_code)"; 
    706716    } 
    707717} 
     
    18731883    my %target_files_key_to_last_update_date_mapping = (); 
    18741884     
    1875     &build_gs3_configuration($target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
     1885    &build_gs3_configuration($translation_file_key, $target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
    18761886     
    18771887    &log_message("Total number of source chunks: " . scalar(keys(%source_files_key_to_text_mapping))); 
     
    19021912    my %target_files_key_to_last_update_date_mapping = (); 
    19031913     
    1904     &build_gs3_configuration($target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping,  
     1914    &build_gs3_configuration($translation_file_key, $target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping,  
    19051915    \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
    19061916     
     
    19251935    # will generate a tar file containing a folder called "greenstone3" with the specified *.properties files 
    19261936 
    1927     my $sourcedir = "greenstone3"; 
    19281937    my $zip = &FileUtils::filenameConcatenate("tmp", "gs3interface_".$target_language_code.".tar.gz"); 
    19291938    my $tar_cmd = "tar -cvzf $zip"; 
     
    19341943    chdir $gsdl_root_directory; 
    19351944 
    1936     my $filelisting = ""; 
    1937     foreach my $interface_file (@gs3_interface_files) { 
     1945    $tar_cmd .= " " . &get_gs3_zip_file_listing($target_language_code, "greenstone3", \@gs3_interface_files); 
     1946    $tar_cmd .= " " . &get_gs3_zip_file_listing($target_language_code, "gs3-collection-configs", \@gs3_col_cfg_files); 
     1947 
     1948    # tar command will overwrite the previous version, but want to check we've created it 
     1949    if(&FileUtils::fileExists($zip)) { 
     1950    &FileUtils::removeFiles($zip); 
     1951    } 
     1952 
     1953    #my $tar_result = system($tar_cmd); # works but then interface breaks 
     1954    `$tar_cmd`; 
     1955    my $tar_result = $?; 
     1956 
     1957    if(&FileUtils::fileExists($zip)) { ## if($tar_result == 0) {, # breaks the interface 
     1958    $download_target_filepath = $zip; 
     1959    } else { 
     1960    &log_message("Unable to generate zip containing gs3interface files " . $download_target_filepath . "$!"); 
     1961    } 
     1962 
     1963    # change back to original working directory (cgi-bin/linux probably) 
     1964    chdir $curdir; 
     1965 
     1966    # ************** END RUDIMENTARY VERSION OF DOWNLOADING LANGUAGE FILES FOR GS3 ************* # 
     1967 
     1968 
     1969    my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, $download_target_filepath, scalar(keys(%source_files_key_to_text_mapping)), 
     1970    \@target_files_keys_requiring_translation, \@target_files_keys_requiring_updating, 
     1971    $num_chunks_to_return, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, 
     1972    \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
     1973     
     1974    return $xml_response; 
     1975} 
     1976 
     1977# helper function 
     1978# gets the listing of gs3 files for a gs3 interface module (gs3interface, gs3colcfg)  
     1979# formatted correctly to go into a zip file 
     1980sub get_gs3_zip_file_listing 
     1981{ 
     1982   my $target_language_code = shift(@_); 
     1983   my $sourcedir = shift(@_);  
     1984   my $files_array = shift(@_); # reference to an array of the interfaces files for the gs3 module 
     1985 
     1986   my $filelisting = ""; 
     1987   foreach my $interface_file (@$files_array) { 
    19381988 
    19391989    my $source_filepath = &FileUtils::filenameConcatenate($sourcedir, $interface_file.".properties"); 
     
    19451995    } 
    19461996    } 
    1947     $tar_cmd .= " $filelisting"; 
    1948  
    1949     # tar command will overwrite the previous version, but want to check we've created it 
    1950     if(&FileUtils::fileExists($zip)) { 
    1951     &FileUtils::removeFiles($zip); 
    1952     } 
    1953  
    1954     #my $tar_result = system($tar_cmd); # works but then interface breaks 
    1955     `$tar_cmd`; 
    1956     my $tar_result = $?; 
    1957  
    1958     if(&FileUtils::fileExists($zip)) { ## if($tar_result == 0) {, # breaks the interface 
    1959     $download_target_filepath = $zip; 
    1960     } else { 
    1961     &log_message("Unable to generate zip containing gs3interface files " . $download_target_filepath . "$!"); 
    1962     } 
    1963  
    1964     # change back to original working directory (cgi-bin/linux probably) 
    1965     chdir $curdir; 
    1966  
    1967     # ************** END RUDIMENTARY VERSION OF DOWNLOADING LANGUAGE FILES FOR GS3 ************* # 
    1968  
    1969  
    1970     my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, $download_target_filepath, scalar(keys(%source_files_key_to_text_mapping)), 
    1971     \@target_files_keys_requiring_translation, \@target_files_keys_requiring_updating, 
    1972     $num_chunks_to_return, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping, 
    1973     \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
    1974      
    1975     return $xml_response; 
     1997 
     1998   return $filelisting; 
    19761999} 
    19772000 
     
    19952018    my %target_files_key_to_last_update_date_mapping = (); 
    19962019     
    1997     &build_gs3_configuration($target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping,  
     2020    &build_gs3_configuration($translation_file_key, $target_language_code, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping,  
    19982021    \%source_files_key_to_last_update_date_mapping, \%target_files_key_to_last_update_date_mapping); 
    19992022     
     
    20222045sub build_gs3_configuration 
    20232046{ 
    2024     my ($target_language_code, $source_files_key_to_text_mapping, $target_files_key_to_text_mapping, 
     2047    my ($translation_file_key, $target_language_code, $source_files_key_to_text_mapping, $target_files_key_to_text_mapping, 
    20252048    $source_files_key_to_gti_comment_or_last_updated_mapping, $target_files_key_to_gti_comment_or_last_updated_mapping, $get_gti_comments_not_last_updated) = @_; 
    20262049     
    20272050    my $source_file_directory = "greenstone3";  # my $source_file_directory = &util::filename_cat("WEB-INF","classes");  
     2051    my $files_array = \@gs3_interface_files; 
     2052 
     2053    if($translation_file_key eq "gs3colcfg") { 
     2054    $source_file_directory = "gs3-collection-configs"; 
     2055    $files_array = \@gs3_col_cfg_files; 
     2056    } 
    20282057    my $translation_file_type = "resource_bundle"; 
    20292058     
    2030     foreach my $interface_file_key (@gs3_interface_files) { 
     2059    foreach my $interface_file_key (@$files_array) { 
    20312060         
    20322061        &log_message("Greenstone 3 interface file: " . $interface_file_key); 
     
    20872116sub write_translated_gs3interface 
    20882117{ 
     2118    my $translation_file_key = shift(@_); 
    20892119    my $source_file_key_to_text_mapping = shift(@_); 
    20902120    my $target_file_key_to_text_mapping = shift(@_); 
     
    21052135     
    21062136    my $source_file_directory = "greenstone3";     
    2107      
     2137    $source_file_directory = "gs3-collection-configs" if $translation_file_key eq "gs3colcfg"; 
     2138 
    21082139    foreach my $interface_file_key (keys(%translated_interface_file_keys)) { 
    21092140         
  • main/trunk/greenstone2/macros/gti.dm

    r29416 r30581  
    191191_gtiviewgs3interfaceinaction_ {It is not possible to view translations of the GS3 interface in action in a GS2 installation.} 
    192192 
     193_gtiviewgs3colcfginaction_ {It is not possible to view translations of the GS3 demo collections' config strings in action in a GS2 installation.} 
     194 
    193195_gtiglihelpzipfilepath_ {} 
    194196 
  • other-projects/gti/translation_status.sh

    r29832 r30581  
    1414fi 
    1515 
    16 filelisting=("macros/*.dm" "perllib/strings*.properties" "gli/classes/dictionary*.properties" "gli/help/" "gsinstaller/LanguagePack*.properties" "greenstone3/*.properties" "greenstoneorg/website/classes/Gsc*.properties") 
     16filelisting=("macros/*.dm" "perllib/strings*.properties" "gli/classes/dictionary*.properties" "gli/help/" "gsinstaller/LanguagePack*.properties" "greenstone3/*.properties" "gs3-collection-configs/*.properties" "greenstoneorg/website/classes/Gsc*.properties") 
    1717 
    1818date=`date +"%d-%m-%y"`