X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/eba2dee941c18b3a1bd9c8af52c01ba7b5b46a64..e18a9d9a881897cbef82adfd992fe0a38c86d8d4:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 45ed96c65..402e960a3 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -486,9 +486,18 @@ sub myurlto ($$;$) { #{{{ # | Helper functions # `---- +sub maybe_add_leading_slash ($;$) { #{{{ + my $str=shift; + my $add=shift; + $add=1 unless defined $add; + return '/' . $str if $add; + return $str; +} #}}} + sub istranslatable ($) { #{{{ my $page=shift; + $page=~s#^/##; my $file=$pagesources{$page}; return 0 unless defined $file; @@ -500,6 +509,7 @@ sub istranslatable ($) { #{{{ sub _istranslation ($) { #{{{ my $page=shift; + my $hasleadingslash = ($page=~s#^/##); my $file=$pagesources{$page}; return 0 unless (defined $file && defined pagetype($file) @@ -512,15 +522,16 @@ sub _istranslation ($) { #{{{ && defined $pagesources{$masterpage} && defined $config{po_slave_languages}{$lang}); - return ($masterpage, $lang) if istranslatable($masterpage); + return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang); } #}}} sub istranslation ($) { #{{{ my $page=shift; if (1 < (my ($masterpage, $lang) = _istranslation($page))) { + my $hasleadingslash = ($masterpage=~s#^/##); $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang}; - return ($masterpage, $lang); + return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang); } return; } #}}}