]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po: fixed link to homepage from non-translation page
authorintrigeri <intrigeri@boum.org>
Tue, 11 Nov 2008 14:01:16 +0000 (15:01 +0100)
committerintrigeri <intrigeri@boum.org>
Tue, 11 Nov 2008 14:06:26 +0000 (15:06 +0100)
Added testcases for this bug.
It remains broken when generated from <TMPL_VAR BASEURL>, though.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
t/po.t

index 164d35270d986ffd1f110e079ef96f610654e854..42a125808addaa570f4157d2dfa2c089a7ecbfff 100644 (file)
@@ -427,7 +427,6 @@ sub myurlto ($$;$) { #{{{
        # workaround hard-coded /index.$config{htmlext} in IkiWiki::urlto()
        if (! length $to
            && $config{po_link_to} eq "current"
        # workaround hard-coded /index.$config{htmlext} in IkiWiki::urlto()
        if (! length $to
            && $config{po_link_to} eq "current"
-           && istranslation($from)
            && istranslatable('index')) {
                return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . lang($from) . ".$config{htmlext}");
        }
            && istranslatable('index')) {
                return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . lang($from) . ".$config{htmlext}");
        }
diff --git a/t/po.t b/t/po.t
index 9c6c6da6c6eede04d06de92eae8a590a966b3308..be446f10817f04d9ecb842907c166fb6bd278a35 100755 (executable)
--- a/t/po.t
+++ b/t/po.t
@@ -17,7 +17,7 @@ BEGIN {
        }
 }
 
        }
 }
 
-use Test::More tests => 52;
+use Test::More tests => 58;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -144,6 +144,17 @@ is(targetpage('test1.fr', 'html'), 'test1/index.fr.html', "$msgprefix test1.fr")
 is(targetpage('test3', 'html'), 'test3/index.html', "$msgprefix test3 (non-translatable page)");
 is(targetpage('test3.es', 'html'), 'test3.es/index.html', "$msgprefix test3.es (non-translatable page)");
 
 is(targetpage('test3', 'html'), 'test3/index.html', "$msgprefix test3 (non-translatable page)");
 is(targetpage('test3.es', 'html'), 'test3.es/index.html', "$msgprefix test3.es (non-translatable page)");
 
+### urlto -> index
+$config{po_link_to}='current';
+$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 -> ''");
+$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 -> ''");
+
 ### bestlink
 $config{po_link_to}='current';
 $msgprefix="bestlink (po_link_to=current)";
 ### bestlink
 $config{po_link_to}='current';
 $msgprefix="bestlink (po_link_to=current)";