MapTools.org

[Chameleon] language change

Jason Fournier jfournier@dmsolutions.ca
Fri, 26 Mar 2004 10:26:36 -0500
Debbie,

The implementation of the Language widget should be identical in CWC2 as 
it is in Chameleon.  Out of curiousity ... if you place the following js 
function in the HEAD of your template does it work?:

/**
 * set the current language
 */
function setLanguage(szLanguage)
{
    aLanguages = new Array();
    aLanguages[aLanguages.length] = new Array( "en-CA" );
    aLanguages[aLanguages.length] = new Array( "fr-CA" );


    bValid = false;
    for( i=0; i< aLanguages.length; i++ )
    {
        if ( aLanguages[i][0] == szLanguage )
        {
            bValid = true;
            break;
        }
    }
    document.forms[0].LANGUAGE.value = szLanguage;
    document.forms[0].submit();
    return true;

}

Jason







Debbie Pagurek wrote:

> Hi all,
> I hate to muddy the waters on the Chameleon list, but I also have 
> the old CWC2 product installed on my systems and I'd like to get the 
> language translation working there as well.  However, I keep seeing a 
> javascript error that says that setLanguage is undefined.
>  
> Jason or anyone else...
> how is the Language widget used in the old CWC2 product?  What is the 
> difference between implementing it in CWC2 vs the latest Chameleon 
> version?
>  
> Thanks for your help.
>  
> D. Pagurek
>
>
> >>> Jason Fournier <jfournier@dmsolutions.ca> 03/23/04 05:40PM >>>
> Debbie,
>
> Along with the required SharedResource Declaration you will have to add
> the following lines just before you initialize the application
> index.phtml.  Here's an example:
>
> $oApp =  new MapApp(); // this is the class in index.phtml which extends
> the Chameleon class
> $oApp->CWCAddRegionalTemplate( "en-CA", "mymap_en.html");
> $oApp->CWCAddRegionalTemplate( "fr-CA", "mymap_fr.html");
> $oApp->CWCInitialize( $szTemplate, $szMapFile  );
>
> This assumes that you have created mymap_en.html and mymap_fr.html.
>
> To switch over, for example, from an English to French template you
> would add a link in your english template similar to:
>
> <a href="javascript:setLanguage('fr-CA');">Français</a>
>
> The MLT should handle translation between English and French for the
> widgets you are using.
>
> I believe this should do it.
>
> Jason
>
>
>
> Debbie Pagurek wrote:
>
> > Hi all,
> > can anyone give me some pointers on how to use the language widget?
> > 
> > <cwc2 type="language">
> > <language name="en-CA"/>
> > <language name="fr-CA"/>
> > </cwc2>
> > 
> > What are the supporting things needed to make this work?
> > 
> > I would like to switch between english and french.  What else needs to
> > be in my template files (both the english and french .html files) to
> > make the switch happen?  I see that there is a function
> > CWCSetLanguage(szTmpLanguage)  in the cwcjsapi.js file - do I need to
> > use this?  And if so, how?  I'm not sure if that .js file is for the
> > old CWC2 product or not.
> > 
> > Please, anyone who can provide info for me on how to switch language
> > templates, I'd really appreciate the help.
> > 
> > Thanks,
> > D. Pagurek
>
>
> -- 
> ___________________________
> Jason Fournier
> DM Solutions Group
> Application Developer
> Ottawa, ON
> 613.565.5056 x 18
> jfournier@dmsolutions.ca
>
>
>

-- 
___________________________
Jason Fournier
DM Solutions Group
Application Developer
Ottawa, ON
613.565.5056 x 18
jfournier@dmsolutions.ca





This archive was generated by Pipermail.