po: fixed link to home page when po_link_to=negotiated, added testcase

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2008-11-11 18:42:14 +01:00
parent 4c45dfce19
commit f0abaa9fc9
2 changed files with 5 additions and 3 deletions

View File

@ -406,6 +406,7 @@ sub mybeautify_urlpath ($) { #{{{
my $res=$origsubs{'beautify_urlpath'}->($url);
if ($config{po_link_to} eq "negotiated") {
$res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!;
$res =~ s!/\Qindex.$config{htmlext}\E$!/!;
}
return $res;
} #}}}

7
t/po.t
View File

@ -150,10 +150,11 @@ $msgprefix="urlto (po_link_to=current)";
is(urlto('', 'index'), './index.en.html', "$msgprefix index -> ''");
is(urlto('', 'nontranslatable'), './../index.en.html', "$msgprefix nontranslatable -> ''");
is(urlto('', 'translatable.fr'), './../index.fr.html', "$msgprefix translatable.fr -> ''");
$config{po_link_to}='negotiated';
$msgprefix="urlto (po_link_to=negotiated)";
is(urlto('', 'index'), './index.en.html', "$msgprefix index -> ''");
is(urlto('', 'nontranslatable'), './../index.en.html', "$msgprefix nontranslatable -> ''");
is(urlto('', 'translatable.fr'), './../index.fr.html', "$msgprefix translatable.fr -> ''");
is(urlto('', 'index'), './', "$msgprefix index -> ''");
is(urlto('', 'nontranslatable'), './../', "$msgprefix nontranslatable -> ''");
is(urlto('', 'translatable.fr'), './../', "$msgprefix translatable.fr -> ''");
### bestlink
$config{po_link_to}='current';