po: added a needstranslation() pagespec
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index ac4401e48fa1d40a75346b768628380f6c24e57f..552b6b51bea28a676639f91c584a98767238f277 100644 (file)
@@ -259,11 +259,9 @@ sub filter (@) {
        my $page = $params{page};
        my $destpage = $params{destpage};
        my $content = $params{content};
+       my $fullpage = $params{fullpage};
 
-       my @caller = caller(4);
-       # FIXME: need to whitelist inline as well?
-        unless ($caller[3] eq "IkiWiki::render" ||
-                $caller[3] eq 'IkiWiki::Plugin::sidebar::sidebar_content') {
+       unless ($fullpage) {
                return $content;
        }
 
@@ -1293,4 +1291,19 @@ sub match_currentlang ($$;@) {
        }
 }
 
+sub match_needstranslation ($$;@) {
+       my $page=shift;
+
+       my $percenttranslated=IkiWiki::Plugin::po::percenttranslated($page);
+       if ($percenttranslated eq 'N/A') {
+               return IkiWiki::FailReason->new("file is not a translation page");
+       }
+       elsif ($percenttranslated < 100) {
+               return IkiWiki::SuccessReason->new("file has $percenttranslated translated");
+        }
+       else {
+               return IkiWiki::FailReason->new("file is fully translated");
+       }
+}
+
 1