]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/po.pm
Merge commit 'upstream/master' into pub/master
[git.ikiwiki.info.git] / IkiWiki / Plugin / po.pm
index 59d938d821151a1f9f0ec3bac27c1a18f8c406ec..9dda8c0db29d8116acb7e4417276865bbe462897 100644 (file)
@@ -204,8 +204,8 @@ sub needsbuild () { #{{{
                IkiWiki::refresh();
                IkiWiki::saveindex();
                # refresh module's private variables
                IkiWiki::refresh();
                IkiWiki::saveindex();
                # refresh module's private variables
-               %filtered=undef;
-               %translations=undef;
+               undef %filtered;
+               undef %translations;
                foreach my $page (keys %pagesources) {
                        istranslation($page);
                }
                foreach my $page (keys %pagesources) {
                        istranslation($page);
                }
@@ -391,6 +391,7 @@ sub otherlanguages ($) { #{{{
 sub pagetemplate (@) { #{{{
        my %params=@_;
         my $page=$params{page};
 sub pagetemplate (@) { #{{{
        my %params=@_;
         my $page=$params{page};
+        my $destpage=$params{destpage};
         my $template=$params{template};
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
         my $template=$params{template};
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
@@ -417,6 +418,24 @@ sub pagetemplate (@) { #{{{
                        }
                }
        }
                        }
                }
        }
+       # 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)) {
+               my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+               $template->param('discussionlink' => htmllink(
+                                                       $page,
+                                                       $destpage,
+                                                       $masterpage . '/' . gettext("Discussion"),
+                                                       noimageinline => 1,
+                                                       forcesubpage => 0,
+                                                       linktext => gettext("Discussion"),
+                                                       ));
+       }
 } # }}}
 
 sub istranslatable ($) { #{{{
 } # }}}
 
 sub istranslatable ($) { #{{{