aboutsummaryrefslogtreecommitdiff
path: root/doc/todo
diff options
context:
space:
mode:
authorlamby@8534e4c2b408c76c30ab7bf8979fdb14963b7ed5 <lamby@web>2018-06-28 14:52:34 -0400
committeradmin <admin@branchable.com>2018-06-28 14:52:34 -0400
commit49b556bc0b0cb9b0e6935b18cc0a41c75667e2d1 (patch)
treeb8ae9c67e8d753c3ff2db70f08aa700437ccf85a /doc/todo
parent3bae786e84ef4f4236b5d9f6db12809b241c65a9 (diff)
downloadikiwiki-49b556bc0b0cb9b0e6935b18cc0a41c75667e2d1.tar
ikiwiki-49b556bc0b0cb9b0e6935b18cc0a41c75667e2d1.tar.gz
Diffstat (limited to 'doc/todo')
-rw-r--r--doc/todo/Re-use_translated_content_instead_of_skipping_if_previously_translated.mdwn86
1 files changed, 86 insertions, 0 deletions
diff --git a/doc/todo/Re-use_translated_content_instead_of_skipping_if_previously_translated.mdwn b/doc/todo/Re-use_translated_content_instead_of_skipping_if_previously_translated.mdwn
new file mode 100644
index 000000000..1830e9f50
--- /dev/null
+++ b/doc/todo/Re-use_translated_content_instead_of_skipping_if_previously_translated.mdwn
@@ -0,0 +1,86 @@
+ From: Chris Lamb <lamby@debian.org>
+ Date: Thu, 28 Jun 2018 19:30:15 +0100
+ Subject: [PATCH] Re-use translated content instead of skipping if previously
+ translated.
+
+ This fixes an issue where an initial `inline` directive would be translated
+ correctly, but subsequent inlines of the same would result in the raw
+ contents of the `.po` file being inserted into the page instead.
+
+ For example, given a `index.mdwn` containing:
+
+ \[[!inline pages="inline" raw="yes"]]
+ \[[!inline pages="inline" raw="yes"]]
+
+ .. and an `index.de.po` of:
+
+ msgid "\[[!inline pages=\"inline\" raw=\"yes\"]]\n"
+ msgstr "\[[!inline pages=\"inline.de\" raw=\"yes\"]]\n"
+
+ .. together with an `inline.mdwn` of:
+
+ This is inlined content.
+
+ .. and an `inline.de.po` of:
+
+ msgid "This is inlined content."
+ msgstr "This is German inlined content."
+
+ .. would result in the following translation:
+
+ This is the inlined content.
+ # SOME DESCRIPTIVE TITLE
+ # Copyright (C) YEAR Free Software Foundation, Inc.
+ # This file is distributed under the same license as the PACKAGE package.
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+
+ .. instead of, of course:
+
+ This is the inlined content.
+ This is the inlined content.
+ ---
+ IkiWiki/Plugin/po.pm | 15 +++++++++------
+ 1 file changed, 9 insertions(+), 6 deletions(-)
+
+ diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
+ index 418e8e58a..ecd1f5499 100644
+ --- a/IkiWiki/Plugin/po.pm
+ +++ b/IkiWiki/Plugin/po.pm
+ @@ -303,9 +303,12 @@ sub filter (@) {
+ my $page = $params{page};
+ my $destpage = $params{destpage};
+ my $content = $params{content};
+ - if (istranslation($page) && ! alreadyfiltered($page, $destpage)) {
+ - $content = po_to_markup($page, $content);
+ - setalreadyfiltered($page, $destpage);
+ + if (istranslation($page)) {
+ + if (!defined(alreadyfiltered($page, $destpage))) {
+ + $content = po_to_markup($page, $content);
+ + setalreadyfiltered($page, $destpage, $content);
+ + }
+ + $content = alreadyfiltered($page, $destpage);
+ }
+ return $content;
+ }
+ @@ -747,15 +750,15 @@ sub myisselflink ($$) {
+ my $page=shift;
+ my $destpage=shift;
+
+ - return exists $filtered{$page}{$destpage}
+ - && $filtered{$page}{$destpage} eq 1;
+ + return $filtered{$page}{$destpage};
+ }
+
+ sub setalreadyfiltered($$) {
+ my $page=shift;
+ my $destpage=shift;
+ + my $content=shift;
+
+ - $filtered{$page}{$destpage}=1;
+ + $filtered{$page}{$destpage}=$content;
+ }
+
+ sub unsetalreadyfiltered($$) {
+ --
+ 2.18.0
+