summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-08-02 12:09:15 +0200
committerintrigeri <intrigeri@boum.org>2010-08-02 12:52:10 +0200
commitd9f0b56a412799feafe041b088db327a4d373c6e (patch)
tree1056067c76368d78530d5a64d32ec131b70cc700
parent22d982243716bb04f56e4e78e573e3ec49077309 (diff)
po(mybestlink): avoid linking to non-existent translation pages.
-rw-r--r--IkiWiki/Plugin/po.pm11
1 files changed, 10 insertions, 1 deletions
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;