]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/po.pm
po: do not add translation status to parentlinks
[git.ikiwiki.info.git] / IkiWiki / Plugin / po.pm
index 01912f813d2c384c63aea704060c90e29f4e3e65..1575754834d646fc73f5c960b2eb6b08a6c9122d 100644 (file)
@@ -39,7 +39,7 @@ sub import {
        hook(type => "rename", id => "po", call => \&renamepages, first => 1);
        hook(type => "delete", id => "po", call => \&mydelete);
        hook(type => "change", id => "po", call => \&change);
-       hook(type => "cansave", id => "po", call => \&cansave);
+       hook(type => "cansave", id => "po", call => \&cansave);
        hook(type => "canremove", id => "po", call => \&canremove);
        hook(type => "canrename", id => "po", call => \&canrename);
        hook(type => "editcontent", id => "po", call => \&editcontent);
@@ -503,15 +503,6 @@ sub formbuilder (@) {
                        }
                }
        }
-
-       # Prevent invalid PO content to be saved.
-       # This cannot be done in the formbuilder_setup hook as the editpage plugin
-       # unconditionally sets the editcontent field's validate code later.
-       elsif ($form->field("do") eq "edit") {
-               if (istranslation($form->field("page"))) {
-                       $form->field(name => "editcontent", validate => \&isvalidpo);
-               }
-       }
 }
 
 # ,----
@@ -602,6 +593,9 @@ sub mynicepagetitle ($;$) {
        my $res = $origsubs{'nicepagetitle'}->($page, $unescaped);
        return $res unless istranslation($page);
        return $res unless $config{po_translation_status_in_links};
+       my @caller = caller(1);
+       return $res if (exists $caller[3] && defined $caller[3]
+                       && $caller[3] eq "IkiWiki::Plugin::parentlinks::parentlinks");
        return $res.' ('.percenttranslated($page).' %)';
 }
 
@@ -1066,7 +1060,8 @@ sub isvalidpo ($) {
        if ($res) {
            return IkiWiki::SuccessReason->new("valid gettext data");
        }
-       return IkiWiki::FailReason->new("invalid gettext data");
+       return IkiWiki::FailReason->new("invalid gettext data, go back ".
+                                       "to previous page to go on with edit");
 }
 
 # ,----