]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po: also filter sidebar translation pages
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index 86d5087f474f7be108239e3fe79f0c27506cd6e9..6bf09b6d660cd97f76c28266ad159c2ceb930b11 100644 (file)
@@ -64,6 +64,8 @@ sub import {
                inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
                $origsubs{'rootpage'}=\&IkiWiki::rootpage;
                inject(name => "IkiWiki::rootpage", call => \&myrootpage);
+               $origsubs{'isselflink'}=\&IkiWiki::isselflink;
+               inject(name => "IkiWiki::isselflink", call => \&myisselflink);
        }
 }
 
@@ -241,6 +243,13 @@ sub filter (@) {
        my $page = $params{page};
        my $destpage = $params{destpage};
        my $content = $params{content};
+
+       my @caller = caller(4);
+        unless ($caller[3] eq "IkiWiki::render" ||
+                $caller[3] eq 'IkiWiki::Plugin::sidebar::sidebar_content') {
+               return $content;
+       }
+
        if (istranslation($page) && ! alreadyfiltered($page, $destpage)) {
                $content = po_to_markup($page, $content);
                setalreadyfiltered($page, $destpage);
@@ -675,6 +684,17 @@ sub myrootpage (@) {
        return $rootpage;
 }
 
+sub myisselflink ($$) {
+       my $page=shift;
+       my $link=shift;
+
+       return 1 if $origsubs{'isselflink'}->($page, $link);
+       if (istranslation($page)) {
+               return $origsubs{'isselflink'}->(masterpage($page), $link);
+        }
+       return;
+}
+
 # ,----
 # | Blackboxes for private data
 # `----