When the nsgmls parser is missing po4a-translate just reports success
and that the documentation is translated to 100% when in fact it does
nothing. This could be pretty confusing. Reporting that nsgmls is
missing would be better.
So I propose this patch to detect that nsgmls is missing and issue an
error. The trick here is we run it on an empty Sgml document and check
that it returned success which should ensure that it works, etc. The
'document' in question uses DocBook and that may be an issue if all the
user wants to use if DebianDoc or some other Sgml document type. Also
the check is performed in initialize() and this may not be the best place.
Alternate solutions would be to:
* we could look for nsgmls in $PATH manually and issue an error if we
could not find it.
* we could check nsgmls' return code after the close(IN) in parse().
What makes this tricky is the way we invoke nsgmls but I think it would
be feasible anyway.
So let me know which approach seems best.
Changelog:
* lib/Locale/Po4a/Sgml.pm
Francois Gouget <fgouget(a)codeweavers.com>
Check for nsgmls and issue an error if it is missing.
--
Francois Gouget
fgouget(a)codeweavers.com
Index: lib/Locale/Po4a/Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.55
diff -u -p -r1.55 Sgml.pm
--- lib/Locale/Po4a/Sgml.pm 21 May 2005 18:42:21 -0000 1.55
+++ lib/Locale/Po4a/Sgml.pm 25 May 2005 01:04:39 -0000
@@ -195,7 +195,15 @@ my $xmlprolog = undef; # the '<?xml ...
sub initialize {
my $self = shift;
my %options = @_;
-
+
+ # Check that nsgmls is installed
+ my $cmd="echo '<!doctype article PUBLIC \"-//OASIS//DTD DocBook
V3.1//EN\"><article><para></para></article>' | nsgmls
2>&1";
+ my $output=`$cmd`;
+ if ($? != 0)
+ {
+ die "po4a::sgml: nsgmls is missing or non-functional:\n$output";
+ }
+
$self->{options}{'translate'}='';
$self->{options}{'section'}='';
$self->{options}{'indent'}='';