RV: [Chameleon] Add new language, template chameleon, please help

Normand Savard nsavard at mapgears.com
Wed Jul 19 11:03:55 EDT 2006


Ines wrote:

>Normand,
>
>Thank you very much for your help! I have my page multi-languaje Ok.
>Now, I need to know wich is the correct way to translate the cw2c tags or
>the rest.
>
>I have 3 lenguajes, and 3 templates
>
>I have to translate all text and all images, and I saw that I have to
>translate:
>
>* All images
>* All the text:
>1) Text of ReferenceLayer,
>
>2) NavToolsLayer, TopTabsLayer,
>
>2) I'm not sure if it is the Text of the file.map: can you help me with this
>flie? where is located? The file/s that manage the Lengend and Tools Tab for
>translate the text of Legend tab (grid, popplace, road...) and the images of
>Tools tab like looks the page "sample_bilingual.phtml" at the left of the
>page.
>
>
>So, I need to know if I have to change the text in every CW2C tag  in every
>template to translate the text, and if I have to duplicate the images with
>the correct language and reference every new image in every CW2C tag in
>every template.
>
>  
>
Ines,

I think the best way is to use only one template in which you include 
variables ([$variable$]) for text to be translated.  The translation of 
the text will appear in the resource files, three resources files in 
your case.  For that you have to set the phtml to use the template you 
want like that:

$oApp->CWCAddRegionalTemplate( 'en-CA', 
dirname(__FILE__).'/sample_bilingual.html', 
dirname(__FILE__).'/sample_resource_en.php' );
$oApp->CWCAddRegionalTemplate( 'fr-CA', 
dirname(__FILE__).'/sample_bilingual.html', 
dirname(__FILE__).'/sample_resource_fr.php' );
$oApp->CWCInitialize( dirname(__FILE__).'/sample_bilingual.html', 
$szMapFile  );

The templates will look something like the following.

sample_bilingual.html

          </cwc2></td>
      <td><cwc2 type="Link" linktype="javascript" 
jsfunction="ShowOtherToolsLayer" styleresource="Tabs" 
Image="icons/[$tools_image$]" ImageTip="[$tools_tip$]" toolset="SideTabs">
              <image state="normal"/>
              <image state="hover"/>
              <image state="selected"/>
          </cwc2></td>

tools_enhanced.html

    <tr>
      <!-- LOCATE -->
      <td><cwc2 type="Locate" styleresource="TextButtons"  
popupstyleresource="TextButtons" PopupWidth="460" PopupHeight="550" 
Toolbar="false" Status="false" Menubar="false" 
Image="icons/[$locate_image$]" ImageTip="[$locate_tip$]" Label="Locate" 
ZoomToScale="1000000">
        <image state="normal"/>
        <image state="selected"/>
        <image state="hover"/>
      </cwc2>
      </td>
    </tr>

sample_resource_en.php

<?php

function loadResources($oApp)
{
    $aRes['str1'] = 'English';
    $aRes['str2'] = 'French';
    $aRes['tools_tip'] = 'Other tools';
    $aRes['tools_image'] = 'icon_tab_tools_en.png';
    $aRes['locate_tip'] = 'Find a place or NTS Sheet';
    $aRes['locate_image'] = 'icon_search_en.png';
    $aRes['legend_tip'] = 'Legend;
  
    foreach($aRes as $key=>$val)
    {
        $oApp->setVar($key, $val);
    }
}
?>

sample_resource_fr.php

<?php

function loadResources($oApp)
{
    $aRes['str1'] = 'Fran&ccedil;ais';
    $aRes['str2'] = 'Anglais';
    $aRes['tools_tip'] = 'Autres outils';
    $aRes['tools_image'] = 'icon_tab_tools_fr.png';
    $aRes['locate_tip'] = 'Localiser un endroit ou une feuille NTS';
    $aRes['locate_image'] = 'icon_search_fr.png';
    $aRes['legend_tip'] = 'L&amp;eacute;gende';
   
    foreach($aRes as $key=>$val)
    {
        $oApp->setVar($key, $val);
    }
}
?>




Regards,

Norm







More information about the Chameleon mailing list