Changeset 29415


Ignore:
Timestamp:
2014-11-04T21:15:38+13:00 (9 years ago)
Author:
ak19
Message:

There was no option for downloading language files for GS3. But only if a filepath to that is provided does the other link show up that allows downloading the spreadsheet for offline translation. For now adding in a version that zips up all the GS3 important interface properties files in English, and those in the translator's language where these exist.

File:
1 edited

Legend:

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

    r29413 r29415  
    3737use strict;
    3838use util;
     39use FileUtils;
    3940
    4041my $gsdl_root_directory = "$ENV{'GSDLHOME'}";
     
    99100# check it out as greenstone3
    100101{ 'key' => "gs3interface",
    101 'file_type' => "resource_bundle",
    102 'source_file' => "greenstone3",
    103 'target_file' => "greenstone3"
     102        'file_type' => "resource_bundle",
     103        'source_file' => "greenstone3",
     104        'target_file' => "greenstone3"
    104105}
    105106];
     
    18931894    &log_message("Total number of target chunks requiring translation: " . scalar(@target_files_keys_requiring_translation));
    18941895    &log_message("Total number of target chunks requiring updating: " . scalar(@target_files_keys_requiring_updating));
    1895    
    1896     my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, "", scalar(keys(%source_files_key_to_text_mapping)),
     1896
     1897    my $download_target_filepath = "";
     1898
     1899
     1900    # ****** DOWNLOADING LANGUAGE FILES WAS NOT YET IMPLEMENTED FOR GS3. RUDIMENTARY VERSION ****** #
     1901
     1902    # if there is no copy of the language files for download, there's also no link to the spreadsheet
     1903    # for translating offline. So GS3's download option, we will zip up all the relevant greenstone 3
     1904    # interface *.properties files,and link to that zip as the file for offline translation.
     1905    # Selecting only properties files for English and the language they're working on (if the last exists)
     1906
     1907    # tar -cvzf gs3interface.tar.gz greenstone3/AbstractBrowse.properties greenstone3/AbstractBrowse_nl.properties
     1908    # will generate a tar file containing a folder called "greenstone3" with the specified *.properties files
     1909
     1910    my $sourcedir = "greenstone3";
     1911    my $zip = &FileUtils::filenameConcatenate("tmp", "gs3interface_".$target_language_code.".tar.gz");
     1912    my $tar_cmd = "tar -cvzf $zip";
     1913
     1914
     1915    # store cur dir and cd to gsdlhome to generate the correct path in the zip file
     1916    my $curdir = `pwd`;
     1917    chdir $gsdl_root_directory;
     1918
     1919    my $filelisting = "";
     1920    foreach my $interface_file (@gs3_interface_files) {
     1921
     1922    my $source_filepath = &FileUtils::filenameConcatenate($sourcedir, $interface_file.".properties");
     1923    my $target_filepath = &FileUtils::filenameConcatenate($sourcedir, $interface_file."_".$target_language_code.".properties");
     1924   
     1925    $filelisting = "$filelisting $source_filepath";
     1926    if(&FileUtils::fileExists($target_filepath)) {
     1927        $filelisting = "$filelisting $target_filepath";
     1928    }   
     1929    }
     1930    $tar_cmd .= " $filelisting";
     1931
     1932    # tar command will overwrite the previous version, but want to check we've created it
     1933    if(&FileUtils::fileExists($zip)) {
     1934    &FileUtils::removeFiles($zip);
     1935    }
     1936
     1937    #my $tar_result = system($tar_cmd); # works but then interface breaks
     1938    `$tar_cmd`;
     1939    my $tar_result = $?;
     1940
     1941    if(&FileUtils::fileExists($zip)) { ## if($tar_result == 0) {, # breaks the interface
     1942    $download_target_filepath = $zip;
     1943    } else {
     1944    &log_message("Unable to generate zip containing gs3interface files " . $download_target_filepath . "$!");
     1945    }
     1946
     1947    # change back to original working directory (cgi-bin/linux probably)
     1948    chdir $curdir;
     1949
     1950    # ************** END RUDIMENTARY VERSION OF DOWNLOADING LANGUAGE FILES FOR GS3 ************* #
     1951
     1952
     1953    my $xml_response = &create_xml_response_for_chunks_requiring_work($translation_file_key, $download_target_filepath, scalar(keys(%source_files_key_to_text_mapping)),
    18971954    \@target_files_keys_requiring_translation, \@target_files_keys_requiring_updating,
    18981955    $num_chunks_to_return, \%source_files_key_to_text_mapping, \%target_files_key_to_text_mapping,
Note: See TracChangeset for help on using the changeset viewer.