po: do not inject custom bestlink function when po_link_to eq default
Signed-off-by: intrigeri <intrigeri@boum.org>master
parent
6c0f9c691c
commit
cdc3576c8d
|
@ -51,8 +51,6 @@ sub import {
|
||||||
hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1);
|
hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1);
|
||||||
hook(type => "formbuilder", id => "po", call => \&formbuilder);
|
hook(type => "formbuilder", id => "po", call => \&formbuilder);
|
||||||
|
|
||||||
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
|
||||||
inject(name => "IkiWiki::bestlink", call => \&mybestlink);
|
|
||||||
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
|
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
|
||||||
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
|
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
|
||||||
$origsubs{'targetpage'}=\&IkiWiki::targetpage;
|
$origsubs{'targetpage'}=\&IkiWiki::targetpage;
|
||||||
|
@ -153,6 +151,10 @@ sub checkconfig () {
|
||||||
warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
|
warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
|
||||||
$config{po_link_to}='default';
|
$config{po_link_to}='default';
|
||||||
}
|
}
|
||||||
|
unless ($config{po_link_to} eq 'default') {
|
||||||
|
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
|
||||||
|
inject(name => "IkiWiki::bestlink", call => \&mybestlink);
|
||||||
|
}
|
||||||
|
|
||||||
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
|
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
|
||||||
|
|
||||||
|
@ -543,16 +545,13 @@ sub formbuilder (@) {
|
||||||
# `----
|
# `----
|
||||||
|
|
||||||
# Implement po_link_to 'current' and 'negotiated' settings.
|
# Implement po_link_to 'current' and 'negotiated' settings.
|
||||||
|
# Not injected otherwise.
|
||||||
sub mybestlink ($$) {
|
sub mybestlink ($$) {
|
||||||
my $page=shift;
|
my $page=shift;
|
||||||
my $link=shift;
|
my $link=shift;
|
||||||
|
|
||||||
return $origsubs{'bestlink'}->($page, $link)
|
|
||||||
if $config{po_link_to} eq "default";
|
|
||||||
|
|
||||||
my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
|
my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
|
||||||
if (length $res
|
if (length $res
|
||||||
&& ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated")
|
|
||||||
&& istranslatable($res)
|
&& istranslatable($res)
|
||||||
&& istranslation($page)) {
|
&& istranslation($page)) {
|
||||||
return $res . "." . lang($page);
|
return $res . "." . lang($page);
|
||||||
|
|
Loading…
Reference in New Issue