Index: /main/trunk/greenstone2/bin/script/gti.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/gti.pl	(revision 33435)
+++ /main/trunk/greenstone2/bin/script/gti.pl	(revision 33436)
@@ -594,4 +594,6 @@
 		($source_file, $target_file, $translation_file_type)
 	    = &get_translation_configuration($target_language_code, $translation_file_key);
+
+		#&log_message("********************** START SOURCE ***********************************");
 		
 		# Parse the source language and target language files
@@ -600,4 +602,6 @@
 		%source_file_key_to_text_mapping = &build_key_to_text_mapping(\@source_file_lines, \%source_file_key_to_line_mapping, $translation_file_type);
 		%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);	
+
+		#&log_message("********************** START TARGET ***********************************");
 		
 		@target_file_lines = &read_file_lines(&util::filename_cat($gsdl_root_directory, $target_file));
@@ -626,5 +630,6 @@
     # &log_message("Submission:");
     foreach my $submission_line (@submission_lines) {
-		$submission_line =~ s/\r$//;
+	$submission_line =~ s/\r$//;
+	$submission_line =~ s/ +$//;
 		#&log_message("  $submission_line");
     }
@@ -647,6 +652,6 @@
 			$source_file_chunk_text = &unmake_text_xml_safe($source_file_chunk_text);
 			
-			#&log_message("Source file key: $chunk_key");
-			#&log_message("Source file text: $source_file_chunk_text");
+			#&log_message("Source file key: |$chunk_key|");
+			#&log_message("Source file text: |$source_file_chunk_text|");
 			$source_file_key_to_submission_mapping{$chunk_key} = $source_file_chunk_text;
 		}
@@ -666,6 +671,6 @@
 			$target_file_chunk_text = &unmake_text_xml_safe($target_file_chunk_text);
 			
-			#&log_message("Target file key: $chunk_key");
-			#&log_message("Target file text: $target_file_chunk_text");
+			#&log_message("Target file key: |$chunk_key|");
+			#&log_message("Target file text: |$target_file_chunk_text|");
 			$target_file_key_to_submission_mapping{$chunk_key} = $target_file_chunk_text;
 		}
@@ -691,8 +696,9 @@
 		
 		# Make sure the submitted source chunk matches the source file chunk
-		if ($source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key})) {
+		if ($source_file_key_to_submission_mapping{$chunk_key} ne $source_file_key_to_text_mapping{$chunk_key} 
+		    && $source_file_key_to_submission_mapping{$chunk_key} ne &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key})) {
 		#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})) {
-		    		#print STDERR "**** $source_file_key_to_submission_mapping{$chunk_key}\n";
-				#print STDERR "**** " . &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}) ."\n";
+		    		#&log_message("**** submission source:\n|$source_file_key_to_submission_mapping{$chunk_key}|\n");
+				#&log_message("**** unmake xml safe source:\n|" . &unmake_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}) ."|\n");
 
 			&log_message("Warning: Source chunk $chunk_key has changed (ignoring submission).");
@@ -939,4 +945,8 @@
 		eval "\$key_to_text_mapping{\${chunk_key}} = &import_chunk_from_${translation_file_type}(\$chunk_text)";
 
+		#&log_message("@@@ chunk key: $chunk_key");
+		#&log_message("@@@ source string: |" . $key_to_text_mapping{$chunk_key} . "|");
+		
+		
 		#if($chunk_key =~ m/document\\/) {
 		    #&log_message("Submission source: $source_file_key_to_submission_mapping{$chunk_key}");
@@ -1620,4 +1630,5 @@
 		my $line = $file_lines[$i];
 		$line =~ s/(\s*)$//;  # Remove any nasty whitespace, carriage returns etc.
+		#&log_message("Got line: ".$line);
 		
 		# a property line has a colon/equals sign as separator that is NOT escaped with a backslash (both keys and values
@@ -1765,5 +1776,5 @@
 		my $line = $file_lines[$i];
 		$line =~ s/(\s*)$//;  # Remove any nasty whitespace, carriage returns etc.
-		
+		#&log_message("Got line: ".$line);	
 		# Line contains a string to translate
 		if ($line =~ /^\s*<Text id=\"(.*?)\">/) {
@@ -1774,5 +1785,5 @@
 			# While there is still text of the string to go...
 			my $startline = $i;
-			while ($line !~ /<\/Text>$/) {
+			while ($line !~ /<\/Text>\s*$/) {
 				$i++;
 				if ($i == scalar(@file_lines)) {
@@ -1783,5 +1794,5 @@
 				$line =~ s/<Updated date=\"\d?\d-\D\D\D-\d\d\d\d.*\"\/>$//;
 			}
-			
+			#&log_message("@@@ Line is now: ".$line);
 			# Map from chunk key to line
 			if (!defined($chunk_key_to_line_mapping{$chunk_key})) {
@@ -1805,5 +1816,5 @@
     $chunk_text =~ s/^\s*<Text id=\"(.*?)\">(\s*)//;
     $chunk_text =~ s/<Updated date=\"\d?\d-\D\D\D-\d\d\d\d.*\"\/>$//;
-    $chunk_text =~ s/<\/Text>$//;
+    $chunk_text =~ s/\s*<\/Text>\s*$//;
 	
     return $chunk_text;
