Index: /main/trunk/greenstone2/bin/script/gti.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/gti.pl	(revision 28990)
+++ /main/trunk/greenstone2/bin/script/gti.pl	(revision 28991)
@@ -720,4 +720,12 @@
     }
 
+    
+    my $perllib_path = &util::filename_cat($gsdl_root_directory, "perllib"); # strings.properties
+    my $gliclasses_path = &util::filename_cat($gsdl_root_directory, "gli", "classes"); # dictionary.properties
+    my $os = $^O;
+    my $path_separator = ($^O =~ m/mswin/i) ? ";" : ":";
+    my $xalan_path = &util::filename_cat($classpath, "xalan.jar");
+    $classpath = "$perllib_path$path_separator$gliclasses_path$path_separator$classpath$path_separator$xalan_path";
+
     my $gli_help_directory = &util::filename_cat($gsdl_root_directory, "gli");
     $gli_help_directory = &util::filename_cat($gli_help_directory, "help");
@@ -735,5 +743,30 @@
 	
     my $target_filepath = &util::filename_cat($gsdl_root_directory, $target_file);
-	
+
+    # if gli/help/nl doesn't exist, create it by copying over gli/help/en/help.xml, then process the copied file
+    my ($tailname, $glihelp_lang_dir, $suffix) =  &File::Basename::fileparse($target_filepath, "\\.[^\\.]+\$");    
+    if(!&FileUtils::directoryExists($glihelp_lang_dir)) { 
+
+	# copy across the gli/help/en/help.xml into a new folder for the new language gli/help/<newlang>
+	my $en_glihelp_dir = &util::filename_cat($gli_help_directory, "en");
+	my $en_helpxml_file = &util::filename_cat($en_glihelp_dir, "help.xml");
+	&FileUtils::copyFilesRecursiveNoSVN($en_helpxml_file, $glihelp_lang_dir);
+
+	# In gli/help/<newlang>/help.xml, replace all occurrences of 
+	# <Text id="1">This text in en will be removed for new langcode</Text> 
+	# with <!-- Missing translation: 1 --> 
+	open(FIN,"<$target_filepath") or &throw_fatal_error("Could not open $target_filepath for READING after creating it");
+	my $help_xml_contents;
+	# Read in the entire contents of the file in one hit
+	sysread(FIN, $help_xml_contents, -s FIN);
+	close(FIN);	
+	
+	$help_xml_contents =~ s@<Text id="([^"]+?)">(.*?)</Text>@<!-- Missing translation: $1 -->@sg;
+
+	open(FOUT, ">$target_filepath") or &throw_fatal_error("Could not open $target_filepath for WRITING after creating it");
+	print FOUT $help_xml_contents;
+	close(FOUT);
+    }
+
 	my $perl_exec = &util::get_perl_exec();
 	my $java_exec = "java";
@@ -741,14 +774,23 @@
 		$java_exec = &util::filename_cat($ENV{'JAVA_HOME'}, "bin", "java");
 	}
-	
-    my $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory";
+
+    #my $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory";
+    my $cmd = "$java_exec -DGSDLHOME=$gsdl_root_directory -cp $classpath ApplyXSLT $target_language_code $gen_many_html_xsl_filepath $target_filepath | \"$perl_exec\" -S $split_script_filepath $target_file_directory";
+    #&throw_fatal_error("RAN gti command: $cmd");
     my $response = `$cmd`;
-        
-    $cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null";
+
+    #$cmd = "$java_exec -cp $classpath:$classpath/xalan.jar ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null";
+    $cmd = "$java_exec -cp $classpath -DGSDLHOME=$gsdl_root_directory ApplyXSLT $target_language_code $gen_index_xml_xsl_filepath $target_filepath > " . $target_file_directory . "help_index.xml"; # 2>/dev/null";
     $response = `$cmd`;
-	
+
+    # create a gti/tmp folder, if one doesn't already exist, and store the downloadable zip file in there
+    my $tmpdir = &util::filename_cat($gsdl_root_directory, "tmp");
+    if(!&FileUtils::directoryExists($tmpdir)) {
+	&FileUtils::makeDirectory($tmpdir);
+    }
     #my $zip_file_path = "/greenstone/custom/gti/" . $target_language_code . "_GLIHelp.zip";    
-    my $zip_file_path = &util::filename_cat($gsdl_root_directory, $target_language_code . "_GLIHelp.zip");
+    my $zip_file_path = &util::filename_cat($tmpdir, $target_language_code . "_GLIHelp.zip");
     $cmd = "zip -rj $zip_file_path $target_file_directory -i \*.htm \*.xml";
+
     $response = `$cmd`;
 }
Index: /main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp
===================================================================
--- /main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp	(revision 28990)
+++ /main/trunk/greenstone2/runtime-src/src/recpt/gtiaction.cpp	(revision 28991)
@@ -98,5 +98,5 @@
     java = existing_javahome; 
     java += "/bin/java";
-  } 
+  }
 
 #if defined (__WIN32__)
@@ -696,6 +696,6 @@
  do_gti_request(gti_arguments, logout); 
 
- disp.setmacro("gtiglihelpzipfilepath", "gti", target_language_code + "_GLIHelp.zip");
- disp.setmacro("gtiglihelpzipfilepathUrlsafe", "gti", encodeForURL(target_language_code) + "_GLIHelp.zip");
+ disp.setmacro("gtiglihelpzipfilepath", "gti", "tmp/" + target_language_code + "_GLIHelp.zip");
+ disp.setmacro("gtiglihelpzipfilepathUrlsafe", "gti", "tmp/" + encodeForURL(target_language_code) + "_GLIHelp.zip");
 
  return true;
