summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/po.pm13
-rw-r--r--doc/plugins/po.mdwn33
-rwxr-xr-xt/po.t14
3 files changed, 41 insertions, 19 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index a8d9b9cd9..492b05c47 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -385,14 +385,14 @@ sub editcontent () { #{{{
# | Injected functions
# `----
-# Implement po_link_to=current
+# Implement po_link_to 'current' and 'negotiated' settings.
sub mybestlink ($$) { #{{{
my $page=shift;
my $link=shift;
my $res=$origsubs{'bestlink'}->($page, $link);
if (length $res
- && $config{po_link_to} eq "current"
+ && ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated")
&& istranslatable($res)
&& istranslation($page)) {
return $res . "." . lang($page);
@@ -406,6 +406,10 @@ 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$!/!;
+ map {
+ $res =~ s!/\Qindex.$_.$config{htmlext}\E$!/!;
+ } (keys %{$config{po_slave_languages}});
}
return $res;
} #}}}
@@ -497,7 +501,6 @@ sub _istranslation ($) { #{{{
my $page=shift;
my $file=$pagesources{$page};
-
return 0 unless (defined $file
&& defined pagetype($file)
&& pagetype($file) eq 'po');
@@ -551,7 +554,7 @@ sub otherlanguages($) { #{{{
my %ret;
if (istranslatable($page)) {
- %ret = %{$translations{$page}};
+ %ret = %{$translations{$page}} if defined $translations{$page};
}
elsif (istranslation($page)) {
my $masterpage = masterpage($page);
@@ -698,7 +701,7 @@ sub otherlanguagesloop ($) { #{{{
}
else {
push @ret, {
- url => urlto($otherpage, $page),
+ url => urlto_with_orig_beautiful_urlpath($otherpage, $page),
code => $lang,
language => languagename($lang),
percent => percenttranslated($otherpage),
diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn
index 5cac86d26..eeeabe730 100644
--- a/doc/plugins/po.mdwn
+++ b/doc/plugins/po.mdwn
@@ -496,20 +496,37 @@ gettext/po4a rough corners
into the Pot file, and let it propagate; should be fixed in
`773de05a7a1ee68d2bed173367cf5e716884945a`, time will tell.
-Page titles in links
---------------------
+Better links
+------------
+
+### Subpages
+
+On a translation page, links to subpages should actually be links to
+the master page's subpages. They currently appear as broken links.
-To use the page titles set with the [meta](plugins/meta) plugin when
+### Page title in links
+
+To use the page titles set with the [[meta|plugins/meta]] plugin when
rendering links would be very much nicer, than the current
"filename.LL" format. This is actually a duplicate for
[[bugs/pagetitle_function_does_not_respect_meta_titles]].
+Going to work on this in my `meta` branch.
+
+### Translation status in links
+
+See [[contrib/po]].
+
+### Backlinks
+
+They are not updated when the source page changes (e.g. meta title).
+
Page formats
------------
Markdown is well supported, great, but what about others?
-The [po](plugins/po) uses `Locale::Po4a::Text` for every page format;
+The [[po|plugins/po]] uses `Locale::Po4a::Text` for every page format;
this can be expected to work out of the box with most other wiki-like
formats supported by ikiwiki. Some of their ad-hoc syntax might be
parsed in a strange way, but the worst problems I can imagine would be
@@ -535,8 +552,8 @@ A new `cansave` type of hook would be needed to implement this.
Note: committing to the underlying repository is a way to bypass
this check.
-Broken links
-------------
+Creating new pages on the web
+-----------------------------
See [[contrib/po]].
@@ -544,5 +561,5 @@ Documentation
-------------
Maybe write separate documentation depending on the people it targets:
-translators, wiki administrators, hackers. This plugin is maybe
-complex enough to deserve this.
+translators, wiki administrators, hackers. This plugin may be complex
+enough to deserve this.
diff --git a/t/po.t b/t/po.t
index be446f108..79e087318 100755
--- a/t/po.t
+++ b/t/po.t
@@ -17,7 +17,7 @@ BEGIN {
}
}
-use Test::More tests => 58;
+use Test::More tests => 59;
BEGIN { use_ok("IkiWiki"); }
@@ -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';
@@ -162,7 +163,7 @@ is(bestlink('test1.fr', 'test2'), 'test2.fr', "$msgprefix test1.fr -> test2");
is(bestlink('test1.fr', 'test2.es'), 'test2.es', "$msgprefix test1.fr -> test2.es");
$config{po_link_to}='negotiated';
$msgprefix="bestlink (po_link_to=negotiated)";
-is(bestlink('test1.fr', 'test2'), 'test2', "$msgprefix test1.fr -> test2");
+is(bestlink('test1.fr', 'test2'), 'test2.fr', "$msgprefix test1.fr -> test2");
is(bestlink('test1.fr', 'test2.es'), 'test2.es', "$msgprefix test1.fr -> test2.es");
### beautify_urlpath
@@ -172,5 +173,6 @@ is(IkiWiki::beautify_urlpath('test1/index.en.html'), './test1/index.en.html', "$
is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/index.fr.html', "$msgprefix test1/index.fr.html");
$config{po_link_to}='negotiated';
$msgprefix="beautify_urlpath (po_link_to=negotiated)";
+is(IkiWiki::beautify_urlpath('test1/index.html'), './test1/', "$msgprefix test1/index.html");
is(IkiWiki::beautify_urlpath('test1/index.en.html'), './test1/', "$msgprefix test1/index.en.html");
-is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/index.fr.html', "$msgprefix test1/index.fr.html");
+is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/', "$msgprefix test1/index.fr.html");