[Po4a-commits] "po4a/lib/Locale/Po4a Po.pm,1.44,1.45"

Martin Quinson mquinson at alioth.debian.org
Sat Sep 3 20:22:39 UTC 2005


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv1601

Modified Files:
	Po.pm 
Log Message:
Make sure that we issue a useful error message when the gettextization fails because there is not the same amount of entries; Tell that the gettextization documentation contain some hints to help users in this painful task

Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- Po.pm	24 Jul 2005 17:07:34 -0000	1.44
+++ Po.pm	3 Sep 2005 20:22:36 -0000	1.45
@@ -317,19 +317,31 @@
     my ($poorig,$potrans)=(shift,shift);
 
     my $pores=Locale::Po4a::Po->new();
+    
+    my $please_fail = 0;
+    my $toobad = dgettext("po4a",
+  	"\nThe gettextization failed (once again). Don't give up, gettextizing is a subtle art, ".
+	"but this is only needed once to convert a project to the gorgeous luxus offered ".
+        "by po4a to translators.".
+        "\nPlease refer to the po4a(7) documentation, the section \"HOWTO convert a pre-existing ".
+        "translation to po4a?\" contains several hints to help you in your task");
 
+    # Don't fail right now when the entry count does not match. Instead, give it a try so that the user
+    # can see where we fail (which is probably where the problem is).
     if ($poorig->count_entries() > $potrans->count_entries()) {
 	warn wrap_mod("po4a gettextize", dgettext("po4a",
 	    "Original has more strings than the translation (%d>%d). ".
 	    "Please fix it by editing the translated version to add some dummy entry."),
 		$poorig->count_entries() , $potrans->count_entries());
+        $please_fail = 1;      
     } elsif ($poorig->count_entries() < $potrans->count_entries()) {
 	warn wrap_mod("po4a gettextize", dgettext("po4a",
 	    "Original has less strings than the translation (%d<%d). ".
 	    "Please fix it by removing the extra entry from the translated file. ".
 	    "You may need an addendum (cf po4a(7)) to reput the chunk in place after gettextization. ".
 	    "A possible cause is that a text duplicated in the original is not translated the same way each time. Remove one of the translations, and you're fine."),
-		$poorig->count_entries(), $potrans->count_entries());
+               $poorig->count_entries(), $potrans->count_entries());
+        $please_fail = 1;
     }
 
     if ( $poorig->get_charset =~ /^utf-8$/i ) {
@@ -382,8 +394,8 @@
 		"msgstr (at %s) is of type '%s'.\n".
 		"Original text: %s\n".
 		"Translated text: %s\n".
-	        "(result so far dumped to /tmp/gettextization.failed.po)"),
-		    $reforig, $typeorig, $reftrans, $typetrans, $orig, $trans);
+	        "(result so far dumped to /tmp/gettextization.failed.po)")."%s",
+	        $reforig, $typeorig, $reftrans, $typetrans, $orig, $trans,$toobad);
 	}
 
 	# 
@@ -394,6 +406,7 @@
 	                 'type'  => $typeorig,
 			 'reference' => $reforig);
     }
+    die "$toobad\n" if $please_fail; # make sure we return a useful error message when entry count differ
     return $pores;
 }
 




More information about the Po4a-commits mailing list