po plugin: implemented po_link_to=current

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2008-10-10 17:37:14 +02:00
parent 0791e5afe3
commit 79d6f52d30
2 changed files with 45 additions and 31 deletions

View File

@ -16,6 +16,7 @@ sub import {
hook(type => "checkconfig", id => "po", call => \&checkconfig); hook(type => "checkconfig", id => "po", call => \&checkconfig);
hook(type => "targetpage", id => "po", call => \&targetpage); hook(type => "targetpage", id => "po", call => \&targetpage);
hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath); hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath);
hook(type => "tweakbestlink", id => "po", call => \&tweakbestlink);
hook(type => "filter", id => "po", call => \&filter); hook(type => "filter", id => "po", call => \&filter);
hook(type => "preprocess", id => "translatable", call => \&preprocess_translatable); hook(type => "preprocess", id => "translatable", call => \&preprocess_translatable);
hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "htmlize", id => "po", call => \&htmlize);
@ -105,6 +106,19 @@ sub tweakurlpath ($) { #{{{
return $url; 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, # We use filter to convert PO to the master page's type,
# since other plugins should not work on PO files # since other plugins should not work on PO files
sub filter (@) { #{{{ sub filter (@) { #{{{

View File

@ -46,37 +46,6 @@ languages, such as:
'de' => { 'name' => 'Deutsch', } '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 Internal links
-------------- --------------
@ -112,6 +81,37 @@ page's language, *i.e.*:
- `foo/page/index.LL.html` if `usedirs` is enabled - `foo/page/index.LL.html` if `usedirs` is enabled
- `foo/page.LL.html` if `usedirs` is disabled - `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 Display available translations
------------------------------ ------------------------------