]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/po.pm
po/todo: some testing results
[git.ikiwiki.info.git] / IkiWiki / Plugin / po.pm
index a920618faf5fa49ca053b46f1d67c23320ef9443..1575754834d646fc73f5c960b2eb6b08a6c9122d 100644 (file)
@@ -475,28 +475,32 @@ sub formbuilder_setup (@) {
        }
 }
 
-# Do not allow to create pages of type po: they are automatically created.
-# The main reason to do so is to bypass the "favor the type of linking page
-# on page creation" logic, which is unsuitable when a broken link is clicked
-# on a slave (PO) page.
 sub formbuilder (@) {
        my %params=@_;
        my $form=$params{form};
        my $q=$params{cgi};
 
-       return unless (defined $form->field("do") && $form->field("do") eq "create");
+       return unless defined $form->field("do");
 
-        for my $field ($form->field) {
-               next unless "$field" eq "type";
-               if ($field->type eq 'select') {
-                       # remove po from the types list
-                       my @types = grep { $_ ne 'po' } $field->options;
-                       $field->options(\@types) if scalar @types;
-               }
-               else {
-                       # make sure the default value is not po;
-                       # does this case actually happen?
-                       debug "po(formbuilder) ".gettext("type field is not select - not implemented yet");
+       # Do not allow to create pages of type po: they are automatically created.
+       # The main reason to do so is to bypass the "favor the type of linking page
+       # on page creation" logic, which is unsuitable when a broken link is clicked
+       # on a slave (PO) page.
+       # This cannot be done in the formbuilder_setup hook as the list of types is
+       # computed later.
+       if ($form->field("do") eq "create") {
+               for my $field ($form->field) {
+                       next unless "$field" eq "type";
+                       if ($field->type eq 'select') {
+                               # remove po from the list of types
+                               my @types = grep { $_ ne 'po' } $field->options;
+                               $field->options(\@types) if scalar @types;
+                       }
+                       else {
+                               # make sure the default value is not po;
+                               # does this case actually happen?
+                               debug "po(formbuilder) ".gettext("type field is not select - not implemented yet");
+                       }
                }
        }
 }
@@ -589,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).' %)';
 }
 
@@ -1053,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");
 }
 
 # ,----