]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
Merge commit 'intrigeri/po'
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index 103347c3776f20980ce75b9203614b102f694e2d..792d84261855ccd074421717207d0276cadc1928 100644 (file)
@@ -59,6 +59,8 @@ sub import {
        inject(name => "IkiWiki::urlto", call => \&myurlto);
        $origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
        inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
+       $origsubs{'rootpage'}=\&IkiWiki::rootpage;
+       inject(name => "IkiWiki::rootpage", call => \&myrootpage);
 }
 
 
@@ -152,8 +154,10 @@ sub checkconfig () {
                $config{po_link_to}='default';
        }
        unless ($config{po_link_to} eq 'default') {
-               $origsubs{'bestlink'}=\&IkiWiki::bestlink;
-               inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               if (! exists $origsubs{'bestlink'}) {
+                       $origsubs{'bestlink'}=\&IkiWiki::bestlink;
+                       inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               }
        }
 
        push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
@@ -568,9 +572,8 @@ sub mybestlink ($$) {
        if (length $res
            && istranslatable($res)
            && istranslation($page)
-           # keep masterpage as the rootpage for inline's post form
-           && !(exists $caller[3] && defined $caller[3]
-                && ($caller[3] eq "IkiWiki::rootpage"))) {
+           &&  !(exists $caller[3] && defined $caller[3]
+                 && ($caller[3] eq "IkiWiki::PageSpec::match_link"))) {
                return $res . "." . lang($page);
        }
        return $res;
@@ -653,6 +656,22 @@ sub mycgiurl (@) {
        return $origsubs{'cgiurl'}->(%params);
 }
 
+sub myrootpage (@) {
+       my %params=@_;
+
+       my $rootpage;
+       if (exists $params{rootpage}) {
+               $rootpage=$origsubs{'bestlink'}->($params{page}, $params{rootpage});
+               if (!length $rootpage) {
+                       $rootpage=$params{rootpage};
+               }
+       }
+       else {
+               $rootpage=masterpage($params{page});
+       }
+       return $rootpage;
+}
+
 # ,----
 # | Blackboxes for private data
 # `----