Source: ikiwiki
Version: 3.20180311-1
Severity: important
Tags: patch

Hi,

There is an issue where an initial "inline" directive would be
translated correctly but subsequent inlines of the same page would
result in the raw contents of the ".po" file (ie. starting with the raw
copyright headers!) 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."

§

This 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.

§

Patch against ikiwiki 3.20180311-1 attached.


Best wishes,

-- 
      ,''".
     : :'  :     Chris Lamb
     ". "'"      la...@debian.org / chris-lamb.co.uk
       "-
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 418e8e5..912672a 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -307,6 +307,13 @@ sub filter (@) {
                $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 +754,15 @@ sub myisselflink ($$) {
                my $page=shift;
                my $destpage=shift;
 
-               return exists $filtered{$page}{$destpage}
-                        && $filtered{$page}{$destpage} eq 1;
+               return exists $filtered{$page}{$destpage};
        }
 
-       sub setalreadyfiltered($$) {
+       sub setalreadyfiltered($$$) {
                my $page=shift;
                my $destpage=shift;
+               my $content=shift;
 
-               $filtered{$page}{$destpage}=1;
+               $filtered{$page}{$destpage}=$content;
        }
 
        sub unsetalreadyfiltered($$) {

Reply via email to