[pmwiki-users] Translation problems with form added into $HandleBrowseFmt

Peter Kay pkay42 at gmail.com
Fri Nov 18 16:17:08 CST 2016


I spent a while today searching through code and I have a few bits of
information:

1.  As far as I can tell, XL() doesn't do ANYTHING unless XLPage() has
been called to load translations for a specific language.
2.  We don't notice this in english, because all the $[translate me]
translate tags are in english.
3.  {*$FullName} gets resolved to Main.HomePage [etc] by the main
pmwiki engine, so we don't notice that 'Editing {*$FullName}' isn't
actually getting translated at all, because the engine resolves the
2nd half for us.
4.  {*$FullName} does NOT get resolved by whatever parses
$HTMLFooterFmt (nor in a separate section of $HTMLBrowseFmt)
5.  {$FullName} DOES get resolved (as Main.HomePage [etc]) in both the
main page and $HTMLFooterFmt
6.  For whatever reason, PmWiki has "$[Editing {\$FullName}]" hanging
around in pmwiki.php (around line 2000), which is different from
$[Editing {*$FullName}].  I have no idea why $[Editing {*$FullName}]
is one of only two entries in XLPage with an * instead of {$FullName},
but Site.EditForm does use $[Editing {*$FullName}].
7.  FmtPageName('$[Editing {*$FullName}]') grabs $FullName, resolves
it to Main.HomePage [etc], and happily returns Editing
{*Main.HomePage} [etc].

So translation would work just fine for me if $HTMLFooterFmt had the
same processing as the main page.  Indeed, MarkupToHTML($pagename,
EL['FormText']) gives me "Editing Main.HomePage" - at the price of
eating all of my HTML.  I'll see if I can preserve it with Keep() or
something!

--Peter Kay



On Fri, Nov 11, 2016 at 10:21 AM, Peter Kay <pkay42 at gmail.com> wrote:
> On Fri, Nov 11, 2016 at 7:35 AM, Petko Yotov <5ko at 5ko.fr> wrote:
>> On 2016-11-11 04:09, Peter Kay wrote:
>>> I have a (block level) form I want to add (once) to a page if certain
>> Inline markups are processed before block markups so it "should" work.
>
> Sorry - I was writing this late at night, and wasn't clear.  The
> problem is that it's block level HTML inside inline HTML, so it's not
> valid.
>
> Pmwiki is quite happy to do what I ask it to if I put the block level
> form there ;)
>
>
>>> I have added code to slip it into the $HandleBrowseFmt array (right
>>> before $PageEndFmt) (similar to the way Live Edit does*).
>>>
>>> That works quite well, except....translation strings are behaving
>>> weirdly.  A specific case in point: $[Editing {*$FullName}] .  I
>>> cannot seem to convince pmwiki to properly handle it - instead of
>>> "Editing Main.HomePage" I get "Editing {*Main.HomePage}"  It seems
>>> $FullName is being resolved before the translation?...
>>
>>
>> Do you mean that your adding an entry to $HandleBrowseFmt breaks the
>> existing translations in other entries? Or are the broken translations only
>> inside the newly added entry?
>
>
> If I put $[Editing {*$FullName}] in the text that I add to
> $HandleBrowseFmt, it does not get translated correctly - anything in
> the normal entries looks correct.
>
>
>> If you add HTML to $HandleBrowseFmt and require translations, you can pass
>> the HTML through FmtPageName(). NOT recommended for stuff written by users
>> in a page.
>
>
> I tried FmtPageName.  "Editing {*Main.HomePage}"
>
> XL....well, XL is weird.
>
> global $pagename;
> $pn=ResolvePageName($pagename);
> $fpn=FmtPageName('$[Editing {*$FullName}]', $pn);
> $xl=XL('$[Editing {*$FullName}]');
> SDV($EL['FormText'], "\nTest results: pn: $pn, fpn, $fpn, xl, $xl\n");
>
> If I add the form text to the markup (global $EL; return $EL['FormText'];):
>
> Test results: pn: Main.HomePage, fpn, Editing {*Main.HomePage}, xl,
> Editing Main.HomePage
>
> But from the bottom of the page, added via handlebrowsefmt:
>     global $EL, $HandleBrowseFmt, $PageStartFmt, $PageRedirectFmt, $PageEndFmt;
>     SDV($HandleBrowseFmt,array(&$PageStartFmt, &$PageRedirectFmt, '$PageText',
>         &$EL['FormText'],  //slip ourselves in after page text
>         &$PageEndFmt));
>
>
> Test results: pn: Main.HomePage, fpn, Editing {*Main.HomePage}, xl,
> Editing {*Main.HomePage}
>
>
>
>
>
>> If I need to programmatically add some HTML at the bottom of the page body,
>> I'd add it as an entry not to $HandleBrowseFmt, but to $HTMLFooterFmt:
>>
>>   $HTMLFooterFmt['my-recipe'] = '<form>...</form><script...>';
>>
>> If none of these helps, can we see a snippet with the code and markup rules?
>> I'd like to try to reproduce it.
>
>
> I'll go add my form to the HTMLFooterFmt block, and maybe I won't need
> to worry anymore, altho the question of why XL is behaving differently
> is certainly an intriguing one...
>
> Thanks for the help!!
>
> --Peter



More information about the pmwiki-users mailing list