X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/002d9e3cb52eadc8c2feb6bfac020b0651c6e0b7..98ad266119aaca7fd2b891fb01867cf5e9c46b67:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 00c58fbe5..990847b48 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -51,18 +51,20 @@ sub import { hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1); hook(type => "formbuilder", id => "po", call => \&formbuilder); - $origsubs{'bestlink'}=\&IkiWiki::bestlink; - inject(name => "IkiWiki::bestlink", call => \&mybestlink); - $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; - 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); - $origsubs{'cgiurl'}=\&IkiWiki::cgiurl; - inject(name => "IkiWiki::cgiurl", call => \&mycgiurl); - $origsubs{'rootpage'}=\&IkiWiki::rootpage; - inject(name => "IkiWiki::rootpage", call => \&myrootpage); + if (! %origsubs) { + $origsubs{'bestlink'}=\&IkiWiki::bestlink; + inject(name => "IkiWiki::bestlink", call => \&mybestlink); + $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; + 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); + $origsubs{'cgiurl'}=\&IkiWiki::cgiurl; + inject(name => "IkiWiki::cgiurl", call => \&mycgiurl); + $origsubs{'rootpage'}=\&IkiWiki::rootpage; + inject(name => "IkiWiki::rootpage", call => \&myrootpage); + } } @@ -133,6 +135,7 @@ sub checkconfig () { $field, 'po')); } } + delete $config{po_slave_languages}{$config{po_master_language}{code}};; map { islanguagecode($_) @@ -174,7 +177,6 @@ sub checkconfig () { if ($config{po_master_language}{code} ne 'en') { # Add underlay containing translated source files # for the master language. -print STDERR "added underlay locale/$config{po_master_language}{code}/$underlay\n"; add_underlay("locale/$config{po_master_language}{code}/$underlay") if -d "$config{underlaydirbase}/locale/$config{po_master_language}{code}/$underlay"; } @@ -567,7 +569,7 @@ sub mybestlink ($$) { my $link=shift; return $origsubs{'bestlink'}->($page, $link) - if $config{po_link_to} eq "default"; + if defined $config{po_link_to} && $config{po_link_to} eq "default"; my $res=$origsubs{'bestlink'}->(masterpage($page), $link); my @caller = caller(1); @@ -585,7 +587,7 @@ sub mybeautify_urlpath ($) { my $url=shift; my $res=$origsubs{'beautify_urlpath'}->($url); - if ($config{po_link_to} eq "negotiated") { + if (defined $config{po_link_to} && $config{po_link_to} eq "negotiated") { $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!; $res =~ s!/\Qindex.$config{htmlext}\E$!/!; map { @@ -729,6 +731,7 @@ sub istranslatablefile ($) { my $type=pagetype($file); return 0 if ! defined $type || $type eq 'po'; return 0 if $file =~ /\.pot$/; + return 0 if ! defined $config{po_translatable_pages}; return 1 if pagespec_match(pagename($file), $config{po_translatable_pages}); return; }