summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/po.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index e33133857..4b2990921 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -16,6 +16,7 @@ sub import {
hook(type => "checkconfig", id => "po", call => \&checkconfig);
hook(type => "targetpage", id => "po", call => \&targetpage);
hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath);
+ hook(type => "tweakbestlink", id => "po", call => \&tweakbestlink);
hook(type => "filter", id => "po", call => \&filter);
hook(type => "preprocess", id => "translatable", call => \&preprocess_translatable);
hook(type => "htmlize", id => "po", call => \&htmlize);
@@ -105,6 +106,19 @@ sub tweakurlpath ($) { #{{{
return $url;
} #}}}
+sub tweakbestlink ($$) { #{{{
+ my %params = @_;
+ my $page=$params{page};
+ my $link=$params{link};
+ if ($config{po_link_to} eq "current" && pagespec_match($link, "istranslatable()")) {
+ if (pagespec_match($page, "istranslation()")) {
+ my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ return $link . "." . $curlang;
+ }
+ }
+ return $link;
+} #}}}
+
# We use filter to convert PO to the master page's type,
# since other plugins should not work on PO files
sub filter (@) { #{{{