summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-10-10 17:37:14 +0200
committerintrigeri <intrigeri@boum.org>2008-10-18 15:49:09 +0200
commit79d6f52d307aa587ef63ffc0aa04ab5070bf15cc (patch)
tree098045666e8bc082b48a79766df408802971b463
parent0791e5afe3d8405132adcfd1ebaa8b76d0def3fc (diff)
po plugin: implemented po_link_to=current
Signed-off-by: intrigeri <intrigeri@boum.org>
-rw-r--r--IkiWiki/Plugin/po.pm14
-rw-r--r--doc/plugins/po.mdwn62
2 files changed, 45 insertions, 31 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 (@) { #{{{
diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn
index 0d93aadda..991f25c06 100644
--- a/doc/plugins/po.mdwn
+++ b/doc/plugins/po.mdwn
@@ -46,37 +46,6 @@ languages, such as:
'de' => { 'name' => 'Deutsch', }
}
-
-Server support
-==============
-
-Apache
-------
-
-Using `mod_negotiation` makes it really easy to have Apache serve the
-page in the client's preferred language, if available. This is the
-default Debian Apache configuration.
-
-When `usedirs` is enabled, one has to set `DirectoryIndex index` for
-the wiki context.
-
-Setting `DefaultLanguage LL` (replace `LL` with your default MIME
-language) for the wiki context can be needed, to ensure
-`bla/page/index.en.html` is served as `Content-Language: LL`.
-**FIXME**: is it still needed with the new `.en.html` naming convention?
-
-lighttpd
---------
-
-lighttpd unfortunately does not support content negotiation.
-
-**FIXME**: does `mod_magnet` provide the functionality needed to
- emulate this?
-
-
-TODO
-====
-
Internal links
--------------
@@ -112,6 +81,37 @@ page's language, *i.e.*:
- `foo/page/index.LL.html` if `usedirs` is enabled
- `foo/page.LL.html` if `usedirs` is disabled
+
+Server support
+==============
+
+Apache
+------
+
+Using `mod_negotiation` makes it really easy to have Apache serve the
+page in the client's preferred language, if available. This is the
+default Debian Apache configuration.
+
+When `usedirs` is enabled, one has to set `DirectoryIndex index` for
+the wiki context.
+
+Setting `DefaultLanguage LL` (replace `LL` with your default MIME
+language) for the wiki context can be needed, to ensure
+`bla/page/index.en.html` is served as `Content-Language: LL`.
+**FIXME**: is it still needed with the new `.en.html` naming convention?
+
+lighttpd
+--------
+
+lighttpd unfortunately does not support content negotiation.
+
+**FIXME**: does `mod_magnet` provide the functionality needed to
+ emulate this?
+
+
+TODO
+====
+
Display available translations
------------------------------