From: intrigeri Date: Mon, 2 Aug 2010 10:09:15 +0000 (+0200) Subject: po(mybestlink): avoid linking to non-existent translation pages. X-Git-Tag: 3.20100831~33^2~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d9f0b56a412799feafe041b088db327a4d373c6e;p=ikiwiki.git po(mybestlink): avoid linking to non-existent translation pages. --- diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index a2010e1be..6b708e850 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -583,7 +583,7 @@ sub mybestlink ($$) { my $res=$origsubs{'bestlink'}->(masterpage($page), $link); my @caller = caller(1); if (length $res - && istranslatable($res) + && istranslatedto($res, lang($page)) && istranslation($page) && !(exists $caller[3] && defined $caller[3] && ($caller[3] eq "IkiWiki::PageSpec::match_link"))) { @@ -764,6 +764,15 @@ sub istranslatable ($) { return; } +sub istranslatedto ($$) { + my $page=shift; + my $destlang = shift; + + $page=~s#^/##; + return 0 unless istranslatable($page); + exists $pagesources{otherlanguage_page($page, $destlang)}; +} + sub _istranslation ($) { my $page=shift;