[pmwiki-users] Switching languages

Patrick R. Michaud pmichaud at pobox.com
Fri Jan 28 09:32:47 CST 2005


On Thu, Jan 27, 2005 at 02:35:38PM -0500, claude at montpetit.net wrote:
> 
> I want to replicate the functionality that is on pmwiki.org where the 
> wiki displayed strings are changed when going to different language 
> groups. 

You've already found the correct answer to this question -- i.e.,
to use a per-group customization file to set the language based on
the group's identity, as in creating a local/PmWikiFr.php file that
contains

   <?php if (!defined('PmWiki')) exit();
     XLPage('fr', 'PmWikiFr.XLPage');
   ?>

But there's actually several ways to do it.  On pmwiki.org I actually
do it in local/config.php, by checking for the existence of $Group.XLPage
for whatever group we happen to be in:

   $xlpage = FmtPageName('$Group.XLPage');
   if (PageExists($xlpage)) XLPage($xlpage);

Thus, any group that has an XLPage defined in it gets that XLPage loaded.
This makes it easy for people to create new language translation pages on 
pmwiki.org, because all that is required is to create the XLPage for
a new language group (and pmwiki.org even supplies the template for this).


Also, it's worth noting that $Group, $Name, $FullName, $PageUrl, etc.
aren't global variables -- they exist only inside of the FmtPageName
function (because they're dependent on the specific pagename being
referenced).  Thus, if you want to know the group of the current page,
you have to do 

   $group = FmtPageName('$Group', $pagename);

Pm



More information about the pmwiki-users mailing list