1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
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
[[!tag patch]]
> 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]]
|