From 79d6f52d307aa587ef63ffc0aa04ab5070bf15cc Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 10 Oct 2008 17:37:14 +0200 Subject: po plugin: implemented po_link_to=current Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'IkiWiki') 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 (@) { #{{{ -- cgit v1.2.3