[Chameleon] help
Normand Savard
nsavard at mapgears.com
Thu Jul 20 17:21:18 EDT 2006
Ines wrote:
>Normand,
>Thanks for your help!
>
>I translated everything Ok! with your explications. I have just one template
>and every variable translated. Thank You very very much.
>
>Now, I have to translate every title of the file.map (metadata)
>In the example:
>http://localhost/chameleon/samples/sample_bilingual.phtml
>
>at the left is every link with a title in the legend tab, they are:
>* grid
>* popplace
>* road
>* rail ... etc.
>
>I have to translate that titles. How can I do? I translated the titles with
>variables, but that is not the way for the file.map
>
>Thank you again!
>Ines
>
>
>
>
>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ç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&eacute;gende';
>
> foreach($aRes as $key=>$val)
> {
> $oApp->setVar($key, $val);
> }
>}
>?>
>
>
>
>
>Regards,
>
>Norm
>
>_______________________________________________
>Chameleon mailing list
>Chameleon at lists.maptools.org
>http://lists.maptools.org/mailman/listinfo/chameleon
>
>
Ines,
It was a good question and I need to ask my co-worker Julien for some
help. You need to modify the LegendLayer div in sample_bilingual.html
as follow:
<div id="LegendLayer" name="LegendLayer">
<table>
<cwc2 type="LegendTemplate" visible="true" embedded="true"
template="[$legend_template$]" popupstyleresource="TextButtons"
popupwidth="500" popupheight="400" status="false" menubar="false"/>
<tr>
<td colspan="4"><cwc2 type="UpdateMap" styleresource="TextButtons"
visible="true" image="icons/icon_update.png" imagetip="update map"
label="Update">
<image state="normal"/>
<image state="selected"/>
<image state="hover"/>
</cwc2>
</table>
</div>
Then add the following resource in sample_resource_en.php:
$aRes['legend_template'] = 'legend_template_en.html';
and in sample_resource_fr.php:
$aRes['legend_template'] = 'legend_template_fr.html';
You have to copy legend_template.html under legend_template_en.html and
under legend_template_fr.html. You have to modify one line in
legend_template_en.html:
<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[leg_layer_name]</span></a></td>
for:
<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=LAYER_EN]</span></a></td>
and in legend_template_fr.html you have to change the same line for:
<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=LAYER_FR]</span></a></td>
Finally in your mapfile (here we are talking about chameleon.map) you
have to add two metadata in each layer, one for each language. Here is
an example for one of the layer:
METADATA
"DESCRIPTION" "Parks"
"RESULT_FIELDS" "NAME_E YEAR_EST AREA_KMSQ"
"GROUP" "Polygon"
"LAYER_EN" "park"
"LAYER_FR" "parc"
END
Regards,
Norm
More information about the Chameleon
mailing list