diff options
author | intrigeri <intrigeri@boum.org> | 2008-10-10 17:37:14 +0200 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2008-10-18 15:49:09 +0200 |
commit | 79d6f52d307aa587ef63ffc0aa04ab5070bf15cc (patch) | |
tree | 098045666e8bc082b48a79766df408802971b463 /IkiWiki | |
parent | 0791e5afe3d8405132adcfd1ebaa8b76d0def3fc (diff) |
po plugin: implemented po_link_to=current
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/po.pm | 14 |
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 (@) { #{{{ |