[pmwiki-users] Late translation

Petko Yotov 5ko at 5ko.fr
Sun Jul 21 16:09:23 PDT 2019

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:


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.


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