[pmwiki-users] Translation problems with form added into $HandleBrowseFmt
Petko Yotov
5ko at 5ko.fr
Sat Nov 26 04:53:36 CST 2016
On 2016-11-18 23:17, Peter Kay wrote:
> 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.
This is correct.
> 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.
More precisely, 'Editing {*$FullName}' is first translated to 'Édition
de {*$FullName}' in French. Then the markup engine, via the PageVar()
function, translates '{*$FullName}' to the current page.
FmtPageName() only translates '{$FullName}' and not '{*$FullName}' or
'{OtherPage$FullName}'. It may be a good idea for FmtPageName() to also
translate '{*$FullName}': at that point of the processing just before
printing the HTML, there is no ambiguity what '{*$FullName}' means.
> 4. {*$FullName} does NOT get resolved by whatever parses
> $HTMLFooterFmt (nor in a separate section of $HTMLBrowseFmt)
When you add code in $HTMLFooterFmt it passes through FmtPageName(), the
strings $[...] are translated only via XL() called by FmtPageName(). So
indeed, at that point, we have 'Édition de {*$FullName}', and a little
later in the same function "$FullName" gets expanded, so you see
'Édition de {*Main.HomePage}'.
> 5. {$FullName} DOES get resolved (as Main.HomePage [etc]) in both the
> main page and $HTMLFooterFmt
Yes, {$FullName} means the physical page where the text is written. If
this text comes from an included page or a footer/sidebar page included
from the skin, then it will mean the footer/sidebar.
Compare with {*$FullName} which means the currently browsed page: when
written in an included page, it means the browsed/outer/including page.
This relative variable came with version 2.2.0-beta and was enabled with
2.2.10. There may be an omission in FmtPageName, and it doesn't process
those cases. Fortunately, nobody asked about this in the last 6+ years.
> 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}].
Because of the switch from absolute to relative page variables:
following the logic, {*$FullName} should mean "the current page" while
{$FullName} should mean "the physical PmWikiFr.XLPage with the
translations".
In fact, XLPage strings are not qualified, {$FullName} and {*$FullName}
both relate to the browsed page. Unfortunately, for the XL() function
there is a difference between the two so we have to select one way to
write it.
It may be a good idea to have XL() strip any "*" it finds in the
"{*$PageVariable}" strings. I'll think about it.
Curiously, the French translation has two different strings:
1: Édition de la page PmWikiFr.XLPage
2: Édition de PmWikiFr.XLPage
> 7. FmtPageName('$[Editing {*$FullName}]') grabs $FullName, resolves
> it to Main.HomePage [etc], and happily returns Editing
> {*Main.HomePage} [etc].
Yes, as I explained after 4.
> 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!
Or simply use the "$[Editing {$FullName}]" translation, without the
asterisk.
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