X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8b001dbb00d702fad648c0f313b0d1d6a3827325..3e341e64c2bcb0c6ae4deba8b4b27a24e90c9db6:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index c8ec37c22..643621a91 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -48,6 +48,8 @@ sub import { #{{{ inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); $origsubs{'targetpage'}=\&IkiWiki::targetpage; inject(name => "IkiWiki::targetpage", call => \&mytargetpage); + $origsubs{'urlto'}=\&IkiWiki::urlto; + inject(name => "IkiWiki::urlto", call => \&myurlto); } #}}} sub getsetup () { #{{{ @@ -151,6 +153,11 @@ sub pofile ($$) { #{{{ return File::Spec->catpath('', $dir, $name . "." . $lang . ".po"); } #}}} +sub pofiles ($) { #{{{ + my $masterfile=shift; + return map pofile($masterfile, $_), (keys %{$config{po_slave_languages}}); +} #}}} + sub refreshpot ($) { #{{{ my $masterfile=shift; @@ -256,6 +263,22 @@ sub urlto_with_orig_beautiful_urlpath($$) { #{{{ return $res; } #}}} +sub myurlto ($$;$) { #{{{ + my $to=shift; + my $from=shift; + my $absolute=shift; + + # workaround hard-coded /index.$config{htmlext} in IkiWiki::urlto() + if (! length $to + && $config{po_link_to} eq "current" + && istranslation($from) + && istranslatable('index')) { + my ($masterpage, $curlang) = ($from =~ /(.*)[.]([a-z]{2})$/); + return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . $curlang . ".$config{htmlext}"); + } + return $origsubs{'urlto'}->($to,$from,$absolute); +} #}}} + sub mybestlink ($$) { #{{{ my $page=shift; my $link=shift;