]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/po.pm
po: fixed link to home page when po_link_to=negotiated, added testcase
[git.ikiwiki.info.git] / IkiWiki / Plugin / po.pm
index 164d35270d986ffd1f110e079ef96f610654e854..96ba467c58d63f4c2ec07a78d281c8d60759d3ef 100644 (file)
@@ -285,6 +285,9 @@ sub pagetemplate (@) { #{{{
        if ($template->query(name => "istranslatable")) {
                $template->param(istranslatable => istranslatable($page));
        }
+       if ($template->query(name => "HOMEPAGEURL")) {
+               $template->param(homepageurl => homepageurl($page));
+       }
        if ($template->query(name => "otherlanguages")) {
                $template->param(otherlanguages => [otherlanguagesloop($page)]);
                map add_depends($page, $_), (values %{otherlanguages($page)});
@@ -359,6 +362,10 @@ sub change(@) { #{{{
                resettranslationscache();
                # Trigger a wiki refresh.
                require IkiWiki::Render;
+               # without preliminary saveindex/loadindex, refresh()
+               # complains about a lot of uninitialized variables
+               IkiWiki::saveindex();
+               IkiWiki::loadindex();
                IkiWiki::refresh();
                IkiWiki::saveindex();
        }
@@ -399,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;
 } #}}}
@@ -427,7 +435,6 @@ sub myurlto ($$;$) { #{{{
        # 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}");
        }
@@ -706,6 +713,11 @@ sub otherlanguagesloop ($) { #{{{
                } @ret;
 } #}}}
 
+sub homepageurl (;$) { #{{{
+       my $page=shift;
+
+       return urlto('', $page);
+} #}}}
 
 # ,----
 # | PageSpec's