summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/po.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 0c95f6c14..88985cd12 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -25,6 +25,7 @@ sub import {
hook(type => "tweakbestlink", id => "po", call => \&tweakbestlink);
hook(type => "filter", id => "po", call => \&filter);
hook(type => "htmlize", id => "po", call => \&htmlize);
+ hook(type => "pagetemplate", id => "po", call => \&pagetemplate);
}
sub getsetup () { #{{{
@@ -198,6 +199,49 @@ sub htmlize (@) { #{{{
return IkiWiki::htmlize($page, $page, pagetype($masterfile), $content);
} #}}}
+sub otherlanguages ($) { #{{{
+ my $page=shift;
+ my @ret;
+ if (istranslatable($page)) {
+ foreach my $lang (sort keys %{$translations{$page}}) {
+ push @ret, {
+ url => urlto($translations{$page}{$lang}, $page),
+ code => $lang,
+ language => $config{po_slave_languages}{$lang},
+ master => 0,
+ };
+ }
+ }
+ elsif (istranslation($page)) {
+ my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ push @ret, {
+ url => urlto($masterpage, $page),
+ code => $config{po_master_language}{code},
+ language => $config{po_master_language}{name},
+ master => 1,
+ };
+ foreach my $lang (sort keys %{$translations{$masterpage}}) {
+ push @ret, {
+ url => urlto($translations{$masterpage}{$lang}, $page),
+ code => $lang,
+ language => $config{po_slave_languages}{$lang},
+ master => 0,
+ } unless ($lang eq $curlang);
+ }
+ }
+ return @ret;
+} #}}}
+
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+ my $page=$params{page};
+ my $template=$params{template};
+
+ if ($template->query(name => "otherlanguages")) {
+ $template->param(otherlanguages => [otherlanguages($page)]);
+ }
+} # }}}
+
sub istranslatable ($) { #{{{
my $page=shift;
my $file=$pagesources{$page};