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 <[email protected]> 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, [email protected] 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?


_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to