]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po plugin[filter]: avoid converting more than once per destfile
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index ca59a8c9c9aad654c34bc9d49c8e9151493cbedb..0698b248838451e8788afd2a21a83ddbe0846fd5 100644 (file)
@@ -82,6 +82,7 @@ sub checkconfig () { #{{{
        if ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) {
                error(gettext("po_link_to=negotiated requires usedirs to be set"));
        }
+       push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
 } #}}}
 
 sub scan (@) { #{{{
@@ -139,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;
        }
 
@@ -173,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;
 } #}}}
 
@@ -232,7 +236,7 @@ use IkiWiki 2.00;
 
 sub match_istranslation ($;@) { #{{{
        my $page=shift;
-       if (IkiWiki::Plugins::po::istranslation($page)) {
+       if (IkiWiki::Plugin::po::istranslation($page)) {
                return IkiWiki::SuccessReason->new("is a translation page");
        }
        else {
@@ -242,7 +246,7 @@ sub match_istranslation ($;@) { #{{{
 
 sub match_istranslatable ($;@) { #{{{
        my $page=shift;
-       if (IkiWiki::Plugins::po::istranslatable($page)) {
+       if (IkiWiki::Plugin::po::istranslatable($page)) {
                return IkiWiki::SuccessReason->new("is set as translatable in po_translatable_pages");
        }
        else {