[Chameleon] Dual Language Functionality

Liz Godwin godwin.liz at gmail.com
Tue Jun 27 10:04:25 EDT 2006


Skipped content of type multipart/alternative-------------- next part --------------
<?php
//sample index.phtml file
//changed for MS4W references
    $apppath = "/ms4w/apps/chameleon-2.2/";

    $skinspath = $apppath."/htdocs/skins/";

    //capture language information from get/post - default is english
    $_FORM = array_merge($_GET, $_POST);
    if (isset($_FORM['LANG']) && $_FORM['LANG'] != ""){
        $lang = $_FORM['LANG'];
    } elseif (isset($_FORM['lang']) && $_FORM['lang'] != ""){
        $lang = $_FORM['lang'];
    } elseif (isset($_FORM['LANGUAGE']) && $_FORM['LANGUAGE'] != ""){
        $lang = $_FORM['LANGUAGE'];
    } elseif (isset($_FORM['language']) && $_FORM['language'] != ""){
        $lang = $_FORM['language'];
    } else {
        $lang = "en-CA";
    }

    //create suffix string for filenames
    if (substr(strtolower($lang), 0, 2) == "fr"){
        $ext = "_f";
        $lang = "fr-CA"; // user may have passed "fr-ca" which isn't treated the same
    } else {
        $ext = "_e";
        $lang = "en-CA"; // user may have passed "en-ca" which isn't treated the same
    }

    $szMapFile = "../map/mymapfile".$ext.".map";
    $szTemplate = $skinspath."myskin/templates/template".$ext.".html";

    include( $apppath."htdocs/chameleon.php" );
    ini_set("max_execution_time",600);

    class MyApp extends Chameleon
    {
       function MyApp()
       {
         parent::Chameleon();
         $this->moMapSession = new MapSession_RW;
         $this->moMapSession->setTempDir( getSessionSavePath());
       }
    }

    $oApp =  new MyApp();
    $oApp->mszCurrentLanguage = $lang;
    $oApp->CWCAddRegionalTemplate( $lang, $szTemplate);
    $oApp->registerSkin( 'skins/myskin' );

    $oApp->CWCInitialize($szTemplate, $szMapFile);
    $oApp->mnMinimumMaturityLevel = MATURITY_UNKNOWN;

    $oApp->CWCExecute();

?>


More information about the Chameleon mailing list