[pmwiki-users] Late translation
randy at brownragfilms.com
randy at brownragfilms.com
Sun Jul 21 21:52:16 PDT 2019
That’s elegant.
FYI for the page variables I had to insert a backslash in front of the “$” to get it to work:
$FmtPV['$TranslateSummary'] = 'TranslatePTV($pn,"$:Summary")’; # no backslash
$FmtPV['$TranslateTitle'] = 'TranslatePTV($pn,"\$Title")’; # backslash required
Thanks!
RandyB
> On Jul 21, 2019, at 6:09 PM, Petko Yotov <5ko at 5ko.fr> wrote:
>
> You can create new custom page variables that will do the translation. For example:
>
> function TranslatePTV($pn, $var) {
> return XL( PageVar($pn, $var) );
> }
>
> $FmtPV['$TranslateRole'] = 'TranslatePTV($pn, "$:Role")';
> $FmtPV['$TranslateSummary'] = 'TranslatePTV($pn, "$:Summary")';
> $FmtPV['$TranslateTitle'] = 'TranslatePTV($pn, "$Title")';
>
> Note the quotes.
>
> Every variable that will be translated needs to have an individual $FmtPV entry. If you need to translate page-text-variables, use the "$:" prefix for the second argument; for page-variables, use just "$" like "$Title" above.
>
> Then in your pagelist template you can have:
>
> label="{{=$FullName}$TranslateSummary}"
>
> Or in another page, {Main.WikiSandbox$TranslateRole}
>
> The translation entries are case- and space-sensitive; if it doesn't appear to translate some strings, check that they are exactly as defined in XLPage.
>
> Petko
>
> On 17/07/2019 19:11, randy at brownragfilms.com wrote:
>> I’d like to populate a form’s selection list with text obtained from a
>> page text variable, and show it in the currently selected language if
>> possible.
>> Unsurprisingly, this approach didn't work for me:
>> (:input jumpbox ... label=“$[{{=$FullName}$:PTV}]”:)
>> Does anyone know of a way to do late translation?
More information about the pmwiki-users
mailing list