]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
bugfix: Avoid generating po files for files that are not httmlizable
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index d26c4ab4e071916cb63e9f4be7cc9e4927378187..3d358b3e2a18137d244f6ea4c995433aec05b3c9 100644 (file)
@@ -260,22 +260,20 @@ sub pagetemplate (@) {
                $template->param(otherlanguages => [otherlanguagesloop($page)]);
                map add_depends($page, $_), (values %{otherlanguages($page)});
        }
-       # Rely on IkiWiki::Render's genpage() to decide wether
-       # a discussion link should appear on $page; this is not
-       # totally accurate, though: some broken links may be generated
-       # when cgiurl is disabled.
-       # This compromise avoids some code duplication, and will probably
-       # prevent future breakage when ikiwiki internals change.
-       # Known limitations are preferred to future random bugs.
-       if ($template->param('discussionlink') && istranslation($page)) {
-               $template->param('discussionlink' => htmllink(
-                       $page,
-                       $destpage,
-                       $masterpage . '/' . gettext("Discussion"),
-                       noimageinline => 1,
-                       forcesubpage => 0,
-                       linktext => gettext("Discussion"),
+       if ($config{discussion} && istranslation($page)) {
+               my $discussionlink=gettext("discussion");
+               if ($page !~ /.*\/\Q$discussionlink\E$/i &&
+                  (length $config{cgiurl} ||
+                   exists $links{$masterpage."/".$discussionlink})) {
+                       $template->param('discussionlink' => htmllink(
+                               $page,
+                               $destpage,
+                               $masterpage . '/' . gettext("Discussion"),
+                               noimageinline => 1,
+                               forcesubpage => 0,
+                               linktext => gettext("Discussion"),
                ));
+               }
        }
        # Remove broken parentlink to ./index.html on home page's translations.
        # It works because this hook has the "last" parameter set, to ensure it
@@ -658,7 +656,8 @@ sub istranslatablefile ($) {
        my $file=shift;
 
        return 0 unless defined $file;
-       return 0 if defined pagetype($file) && pagetype($file) eq 'po';
+       my $type=pagetype($file);
+       return 0 if ! defined $type || $type eq 'po';
        return 0 if $file =~ /\.pot$/;
        return 0 unless -e "$config{srcdir}/$file"; # underlay dirs may be read-only
        return 1 if pagespec_match(pagename($file), $config{po_translatable_pages});