- # decide if this is a PO file that should be converted into a translated document,
- # and perform various sanity checks
- if (! istranslation($page) || $filtered{$page}{$destpage}) {
- return $content;
- }
+ return $content if ( ! istranslation($page)
+ || ( exists $filtered{$page}{$destpage}
+ && $filtered{$page}{$destpage} eq 1 ));
+
+ # CRLF line terminators make poor Locale::Po4a feel bad
+ $content=~s/\r\n/\n/g;
+
+ # Implementation notes
+ #
+ # 1. Locale::Po4a reads/writes from/to files, and I'm too lazy
+ # to learn how to disguise a variable as a file.
+ # 2. There are incompatibilities between some File::Temp versions
+ # (including 0.18, bundled with Lenny's perl-modules package)
+ # and others (e.g. 0.20, previously present in the archive as
+ # a standalone package): under certain circumstances, some
+ # return a relative filename, whereas others return an absolute one;
+ # we here use this module in a way that is at least compatible
+ # with 0.18 and 0.20. Beware, hit'n'run refactorers!
+ my $infile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-in.XXXXXXXXXX",
+ DIR => File::Spec->tmpdir,
+ UNLINK => 1)->filename;
+ my $outfile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-out.XXXXXXXXXX",
+ DIR => File::Spec->tmpdir,
+ UNLINK => 1)->filename;
+
+ writefile(basename($infile), File::Spec->tmpdir, $content);