I hit this problem with winedoc because the source English documentation
is in the 'en' subdirectory while the French po files are in the 'fr'
subdirectory.
The way I initially worked around it is by doing the following:
SGMLDIR = $(TOPSRCDIR)/en
DOCDIR = $(TOPSRCDIR)/fr
%.posgml: $(SGMLDIR)/%.sgml %.po
cd $(SGMLDIR) && $(PO4AENV) perl $(PO4ADIR)/po4a-translate -v -f
sgml -m $*.sgml -p $(DOCDIR)/$*.po -l $(DOCDIR)/$*.posgml -k $(MIN_TRANS)
But this does not work for out-of-tree builds because then $(DOCDIR) is
wrong.
So I checked what the standard DocBook tools think about the inclusion
of files. It turns out that 'docbook2html -u ../en/wineusr-guide.sgml'
works just fine despite the fact that 'wineusr-guide.sgml' includes
other Sgml files via relative paths.
So this seems to give credence to the claim that the path of included
files should be interpreted as being relative to the master Sgml file.
So here's a patch which does just that and I think this fixes bug #300874.
This makes it possible to rewrite the above as the following which works
for out-oftree builds too:
SGMLDIR = $(TOPSRCDIR)/en
%.posgml: $(SGMLDIR)/%.sgml %.po
$(PO4AENV) perl $(PO4ADIR)/po4a-translate -v -f sgml -m
$(SGMLDIR)/$*.sgml -p $(SRCDIR)/$*.po -l $*.posgml -k $(MIN_TRANS)
Changelog:
* lib/Locale/Po4a/Sgml.pm
Francois Gouget <fgouget(a)codeweavers.com>
If relative, the path of included file must be considered to be
relative to the path of the master Sgml file.
Fixes bug #300874.
--
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 24 May 2005 11:47:01 -0000
@@ -290,24 +290,24 @@ sub set_tags_kind {
# Do the actual work, using the SGMLS package and settings done elsewhere.
#
sub parse_file {
- my ($self,$filename)=@_;
+ my ($self,$mastername)=@_;
my ($prolog);
# Rewrite the file to:
# - protect optional inclusion marker (ie, "<![ %str [" and
"]]>")
# - protect entities from expansion (ie "&release;")
- open (IN,"<$filename")
- || die wrap_mod("po4a::sgml", dgettext("po4a", "Can't open
%s: %s"), $filename, $!);
+ open (IN,"<$mastername")
+ || die wrap_mod("po4a::sgml", dgettext("po4a", "Can't open
%s: %s"), $mastername, $!);
my $origfile="";
while (<IN>) {
$origfile .= $_;
}
- close IN || die wrap_mod("po4a::sgml", dgettext("po4a",
"Can't close %s: %s"), $filename, $!);
+ close IN || die wrap_mod("po4a::sgml", dgettext("po4a",
"Can't close %s: %s"), $mastername, $!);
# Detect the XML pre-prolog
if ($origfile =~ s/^(\s*<\?xml[^?]*\?>)//) {
warn wrap_mod("po4a::sgml", dgettext("po4a",
"Trying to handle a XML document as a SGML one. ".
- "Feel lucky if it works, help us implementing a proper XML backend if it does
not."), $filename)
+ "Feel lucky if it works, help us implementing a proper XML backend if it does
not."), $mastername)
unless $self->verbose() <= 0;
$xmlprolog=$1;
}
@@ -443,8 +443,8 @@ sub parse_file {
my @lines = split(/\n/, $origfile);
print "XX Prepare reference indirection stuff\n" if
$debug{'refs'};
for (my $i=1; $i<=scalar @lines; $i++) {
- push @refs,"$filename:$i";
- print "$filename:$i\n" if $debug{'refs'};
+ push @refs,"$mastername:$i";
+ print "$mastername:$i\n" if $debug{'refs'};
}
# protect the conditional inclusions in the file
@@ -478,6 +478,12 @@ sub parse_file {
my $key = $2;
my $filename=$3;
$prolog = $1.$4;
+ if ($filename !~ m%/%)
+ {
+ my $dir=$mastername;
+ $dir =~ s%/[^/]*$%%;
+ $filename="$dir/$filename";
+ }
(-e $filename && open IN,"<$filename") ||
die wrap_mod("po4a::sgml", dgettext("po4a", "Can't
open %s (content of entity %s%s;): %s"),
$filename, '%', $key, $!);
@@ -530,6 +536,12 @@ sub parse_file {
my $key = $2;
my $filename = $3;
$searchprolog = $1.$4;
+ if ($filename !~ m%/%)
+ {
+ my $dir=$mastername;
+ $dir =~ s%/[^/]*$%%;
+ $filename="$dir/$filename";
+ }
$entincl{$key}{'filename'}=$filename;
# Preload the content of the entity
(-e $filename && open IN,"<$filename") ||
@@ -588,7 +600,7 @@ sub parse_file {
if ($debug{'refs'}) {
print "XX Resulting shifts\n";
for (my $i=0; $i<scalar @refs; $i++) {
- print "$filename:".($i+1)." -> $refs[$i]\n";
+ print "$mastername:".($i+1)." -> $refs[$i]\n";
}
}