]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po plugin: implemented po_link_to=current
authorintrigeri <intrigeri@boum.org>
Fri, 10 Oct 2008 15:37:14 +0000 (17:37 +0200)
committerintrigeri <intrigeri@boum.org>
Sat, 18 Oct 2008 13:49:09 +0000 (15:49 +0200)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index e331338576b6c46300b1d135b456a65f79902aff..4b29909219ba5a7bb6020943b1d1ce09e08a4112 100644 (file)
@@ -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 (@) { #{{{
index 0d93aaddac1be32d4cbd0d26ea3418bada31a863..991f25c069712c6decb626ae6d8958b608d8c400 100644 (file)
@@ -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
 ------------------------------