1 From: Chris Lamb <lamby@debian.org>
2 Date: Thu, 28 Jun 2018 19:30:15 +0100
3 Subject: [PATCH] Re-use translated content instead of skipping if previously
6 This fixes an issue where an initial `inline` directive would be translated
7 correctly, but subsequent inlines of the same would result in the raw
8 contents of the `.po` file being inserted into the page instead.
10 For example, given a `index.mdwn` containing:
12 \[[!inline pages="inline" raw="yes"]]
13 \[[!inline pages="inline" raw="yes"]]
15 .. and an `index.de.po` of:
17 msgid "\[[!inline pages=\"inline\" raw=\"yes\"]]\n"
18 msgstr "\[[!inline pages=\"inline.de\" raw=\"yes\"]]\n"
20 .. together with an `inline.mdwn` of:
22 This is inlined content.
24 .. and an `inline.de.po` of:
26 msgid "This is inlined content."
27 msgstr "This is German inlined content."
29 .. would result in the following translation:
31 This is the inlined content.
32 # SOME DESCRIPTIVE TITLE
33 # Copyright (C) YEAR Free Software Foundation, Inc.
34 # This file is distributed under the same license as the PACKAGE package.
35 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
37 .. instead of, of course:
39 This is the inlined content.
40 This is the inlined content.
42 IkiWiki/Plugin/po.pm | 15 +++++++++------
43 1 file changed, 9 insertions(+), 6 deletions(-)
45 diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
46 index 418e8e58a..ecd1f5499 100644
47 --- a/IkiWiki/Plugin/po.pm
48 +++ b/IkiWiki/Plugin/po.pm
49 @@ -303,9 +303,12 @@ sub filter (@) {
50 my $page = $params{page};
51 my $destpage = $params{destpage};
52 my $content = $params{content};
53 - if (istranslation($page) && ! alreadyfiltered($page, $destpage)) {
54 - $content = po_to_markup($page, $content);
55 - setalreadyfiltered($page, $destpage);
56 + if (istranslation($page)) {
57 + if (!defined(alreadyfiltered($page, $destpage))) {
58 + $content = po_to_markup($page, $content);
59 + setalreadyfiltered($page, $destpage, $content);
61 + $content = alreadyfiltered($page, $destpage);
65 @@ -747,15 +750,15 @@ sub myisselflink ($$) {
69 - return exists $filtered{$page}{$destpage}
70 - && $filtered{$page}{$destpage} eq 1;
71 + return $filtered{$page}{$destpage};
74 sub setalreadyfiltered($$) {
79 - $filtered{$page}{$destpage}=1;
80 + $filtered{$page}{$destpage}=$content;
83 sub unsetalreadyfiltered($$) {
89 > Thank you Chris! I've reviewed the patch (with my "original author of the po plugin" hat on) and it looks good to me. I'm not 100% sure about `alreadyfiltered` being the best name for something that's not a predicated anymore but it's good enough. Then I wore my end-user hat and confirmed that with Chris' patch applied, the reproducer we had for this bug at Tails works fine. So IMO we're good to go and I recommend to apply this patch. Thanks in advance! -- [[intrigeri]]
92 > Any update on getting this merged? — [[lamby]], Fri, 24 Aug 2018 12:36:37 +0200
94 > Indeed, would love to see this merged! What might be the next steps here? — [[lamby]], Thu, 18 Oct 2018 17:57:37 -0400
96 > I've filed this in Debian GNU/Linux at https://bugs.debian.org/911356 — [[lamby]], Thu, 18 Oct 2018 20:18:58 -0400