[Pmwiki-users] Wikis with multiple languages

Patrick R. Michaud pmichaud
Mon Jan 12 09:15:25 CST 2004


On Mon, Jan 12, 2004 at 11:27:21AM +0100, Dr. Rainer Decker (privat) wrote:
> Hi Patrick,
> But if you do so, wouldn't it be easier to implement a more 
> general syntax similar to the one used e.g. as conditional
> directives in C-compilers:
>     [[if  <condition or function>]]
>          <stuff displayed for condition or function result 'true'>
>     [[else]]
>         <stuff displayed for condition or fucntion result 'false'>
>     [[endif]]
> [...]
> - time dependent text , e.g.
>       [[if  (hour<12) ]]
>        Good morning!
>       [[endif ]]
> and so on.

Well, no, I really don't want to write a whole C-like conditional
expression parser in PmWiki--that seems really overkill, plus the 
syntax of C expressions may alienate many authors.  (Also, one has
to be careful about protecting PHP variables from access/modification
by wiki authors.)

As opposed to using C expressions, I might just use a flag
or function based format...for example, all conditionals would
be in the form

   [[if <test> <param>]]
      <stuff>
   [[endif]]

where <test> is selected from an array of possible tests (definable
by the WikiAdministrator) and <param> is an optional string parameter 
that can be passed to the test.  Example if statements could be...

   [[if lang en]]
   [[if false]]
   [[if printing]]
   [[if daterange 20040110-20040117]]

where a WikiAdmin could define tests as:

   $Conditional['false'] = 0;				
   $Conditional['printing'] = ($action=='print');        
   $Conditional['lang'] = "$_SESSION['lang']=='$1'";    
   $Conditional['daterange'] = "IsDateRange('$1')";	

Pm



More information about the pmwiki-users mailing list