]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po plugin[filter]: avoid converting more than once per destfile
authorintrigeri <intrigeri@boum.org>
Sat, 11 Oct 2008 01:02:43 +0000 (03:02 +0200)
committerintrigeri <intrigeri@boum.org>
Sat, 18 Oct 2008 13:49:10 +0000 (15:49 +0200)
Only the first filter function call on a given {page,destpage} must convert it
from the PO file, subsequent calls must leave the passed $content unmodified.

Else, preprocessing loops are the rule.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm

index d3ccd37e1a407bdd9684044fbf4970ba1b679253..0698b248838451e8788afd2a21a83ddbe0846fd5 100644 (file)
@@ -140,16 +140,18 @@ sub tweakbestlink ($$) { #{{{
        return $link;
 } #}}}
 
+our %filtered;
 # We use filter to convert PO to the master page's type,
 # since other plugins should not work on PO files
 sub filter (@) { #{{{
        my %params = @_;
        my $page = $params{page};
+       my $destpage = $params{destpage};
        my $content = decode_utf8(encode_utf8($params{content}));
 
        # decide if this is a PO file that should be converted into a translated document,
        # and perform various sanity checks
-       if (! istranslation($page)) {
+       if (! istranslation($page) || $filtered{$page}{$destpage}) {
                return $content;
        }
 
@@ -174,6 +176,7 @@ sub filter (@) { #{{{
        my $tmpout = $tmpfh->filename;
        $doc->write($tmpout) or error("[po/filter:$file] could not write $tmpout");
        $content = readfile($tmpout) or error("[po/filter:$file] could not read $tmpout");
+       $filtered{$page}{$destpage}=1;
        return $content;
 } #}}}