X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/c5f1c503cdac65a55e6a796c86fdcc9d0b9ad6d3..8084c79f920e5b4cb961dc6df3641a0253384eb5:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 9ed4a1adb..ec58c515b 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -38,7 +38,8 @@ memoize("percenttranslated"); sub import { hook(type => "getsetup", id => "po", call => \&getsetup); - hook(type => "checkconfig", id => "po", call => \&checkconfig); + hook(type => "checkconfig", id => "po", call => \&checkconfig, + last => 1); hook(type => "needsbuild", id => "po", call => \&needsbuild); hook(type => "scan", id => "po", call => \&scan, last => 1); hook(type => "filter", id => "po", call => \&filter); @@ -65,8 +66,11 @@ 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); + if (IkiWiki->can('rootpage')) { + $origsubs{'rootpage'}=\&IkiWiki::rootpage; + inject(name => "IkiWiki::rootpage", call => \&myrootpage) + if defined $origsubs{'rootpage'}; + } $origsubs{'isselflink'}=\&IkiWiki::isselflink; inject(name => "IkiWiki::isselflink", call => \&myisselflink); } @@ -620,20 +624,24 @@ sub mybeautify_urlpath ($) { return $res; } -sub mytargetpage ($$) { +sub mytargetpage ($$;$) { my $page=shift; my $ext=shift; + my $filename=shift; if (istranslation($page) || istranslatable($page)) { my ($masterpage, $lang) = (masterpage($page), lang($page)); - if (! $config{usedirs} || $masterpage eq 'index') { + if (defined $filename) { + return $masterpage . "/" . $filename . "." . $lang . "." . $ext; + } + elsif (! $config{usedirs} || $masterpage eq 'index') { return $masterpage . "." . $lang . "." . $ext; } else { return $masterpage . "/index." . $lang . "." . $ext; } } - return $origsubs{'targetpage'}->($page, $ext); + return $origsubs{'targetpage'}->($page, $ext, $filename); } sub myurlto ($;$$) { @@ -1237,6 +1245,7 @@ sub po4a_options($) { # how to disable options is not consistent across po4a modules $options{includessi} = ''; $options{includeexternal} = 0; + $options{ontagerror} = 'warn'; } elsif ($pagetype eq 'mdwn') { $options{markdown} = 1;