summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-10-13 22:07:21 +0200
committerintrigeri <intrigeri@boum.org>2008-10-18 15:49:10 +0200
commita28559798ad8c60e79fe80f109dd8e63204cd208 (patch)
tree35433af392d3bf1c0221b6ccf5dec962106033be /IkiWiki/Plugin
parent32cc0b336ae830831787b2024b855ed7db0a1589 (diff)
po plugin: created OTHERLANGUAGES template loop
It currently only provides basic translations/master pages links. Updated documentation accordingly. Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin')
-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};