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

Petko Yotov 5ko at 5ko.fr
Fri Nov 11 06:35:13 CST 2016


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
> markup is present on the page.  Adding it with the first occurrence of
> the markup doesn't work - the markup is inline.

Inline markups are processed before block markups so it "should" work. 
Otherwise, you can call the PRR() function "PmWiki Redo Rules" to 
restart the markup processing from the beginning after your specific 
markup is done. Like PmWiki does with (:include...:).


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

If you have specific strings that need their translations in the PHP 
code, you can use

  $local_string = XL("String to be translated");

Or, to only process the $[...] strings in some HTML, you can use 
something like this:

   $intl = PPRE('/\\$\\[([^\\]]+)\\]/', "XL(\$m[1])", $html);
   (This is how the Abort() function in pmwiki.php does it.)

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.

Petko

---
Change log     :  http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes  :  http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade :  http://www.pmwiki.org/wiki/PmWiki/Upgrades



More information about the pmwiki-users mailing list