[Chameleon] Solution :Help - Translation problem - WMS Layers

Ines mleonsoft at yahoo.com.ar
Tue Aug 15 18:23:48 EDT 2006


Hello Normand and maptools list, 

I was thinking and thinking about this problem, and finally I could
resolve this problem. I maked some changes in the code of the legend
templates and it is working very well. I want to share it with you.

1) Finally, the translation of the "legend" in 3 languages is working
very well, and,
2) When I add a WMS Layer, I can see the name of the new layer in the
"legend" (The WMS layers are not translated)

In the 3 templates I changed the variable "wms_name" for "LAYER_EN", or
LAYER_ES, or LAYER_PT, and validate:


legend_template_en.html:


[if name=LAYER_EN oper=isnull]
	<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=WMS_TITLE]</span></a></td>

  </tr>
    [/if]
    [if name=LAYER_EN oper=isset]
    <td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=LAYER_EN]</span></a></td>
  </tr>
    [/if]
------------------------------------------------------------------------
--------
legend_template_es.html:


[if name=LAYER_ES oper=isnull]
	<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=WMS_TITLE]</span></a></td>

  </tr>
    [/if]
    [if name=LAYER_ES oper=isset]
    <td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=LAYER_ES]</span></a></td>
  </tr>
    [/if]

------------------------------------------------------------------------
-----------

legend_template_pt.html:

[if name=LAYER_PT oper=isnull]
	<td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=WMS_TITLE]</span></a></td>

  </tr>
    [/if]
    [if name=LAYER_PT oper=isset]
    <td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=LAYER_PT]</span></a></td>
  </tr>
    [/if]


Again, thank you very very much for your help

Ines

------------------------------------------------------------------------
---------------------

Ines wrote:

>
>I corrected it, but I have another problem now:
>
>When I add WMS Layers, the layer is added and I can see the name of the

>layer very well. But I can't see my translations of the file.map. I see

>all the names in english at the left menu. When I open the Internet 
>explorer and I run my aplication, and I press the button "spanish" or 
>"portuguese", but the left menu is still in english. The aplication 
>Don't take the variables "LAYER_ES" and "LAYER_PT" from the file.map. 
>But if I add some WMS Layer, I can see the layer in the map, and the 
>name of the new WMS layer very well.
>
>It is the code I have now of the legend_templates and part of the file
>.map:
>
>"legend_template_es.html":
>
>
>[leg_layer_html order=ascending opt_flag=15]
>  <tr bgcolor="#ffffff">
>    <td><input type="radio" name="my_legend" 
>onclick="CWCSelectLayer('[leg_layer_name]', true)"[if name=selected 
>value=1] CHECKED[/if] ></td>
>    <td align="center" width=20><input type="checkbox" 
>name="legendlayername[]" value="[leg_layer_name]"
>    [if name=layer_status oper=eq  value=1]CHECKED[/if]
>    [if name=layer_status oper=eq value=2]CHECKED[/if]></td>
>    <td><a href="[leg_icon width=818 height=900]" target="_blank"><img
>src="[leg_icon width=20 height=18]" width="20" height="20"
>border="0"></a></td>
>    [if name=wms_name oper=isnull]
>    
>	<td><a href="#" 
>onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
>class="label">[metadata name=LAYER_ES]</span></a></td>
>	
>  </tr>
>    [/if]
>    [if name=wms_name oper=isset]
>    <td><a href="#" 
>onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
>class="label">[metadata name=WMS_TITLE]</span></a></td>
>  </tr>
>    [/if]
>[/leg_layer_html]
>
>
>A leyer in the file.map:
>
>
>LAYER
>    CONNECTION 
>"http://mapa.itsc.uah.edu:8080/wmsconnector/com.esri.wms.Esrimap/ccad_v
>e
>ctors?"
>    CONNECTIONTYPE WMS
>    DUMP TRUE
>      METADATA
>        "wms_srs"	"EPSG:4326 EPSG:4267 EPSG:4269 EPSG:4326"
>        "wms_onlineresource"
>"http://mapa.itsc.uah.edu:8080/wmsconnector/com.esri.wms.Esrimap/ccad_v
e
>ctors?"
>        "wms_latlonboundingbox"	"-89.52409 7.00194 -77.00009
18.53164"
>        "layer_index"	"8"
>        "wms_queriable"	"1"
>        "wms_name"	"3"
>        "wms_formatlist"	"image/png,image/jpeg"
>        "wms_format"	"image/png"
>        "selected"	"0"
>        "LEGEND_ORDER"	"8"
>        "wms_server_version"	"1.1.1"
>        "wms_abstract" "Central American River Systems"
>        "wms_metadataurl_href"
>"http://fgdc.er.usgs.gov/metadata/metadata.html"
>        "wms_dataurl_href"
>"http://servir.nsstc.nasa.gov/MesoStor/index.html"
>        "wms_title"	"Rivers of C.A."
>	  "LAYER_EN" "Rivers of C.A."
>	  "LAYER_ES" "Ríos de C.A."
>	  "LAYER_PT" "Rios de C.A."
>		
>      END
>
>
>  
>
Ines,

Based on the layer description in the map file above this is a WMS layer

(CONNECTIONTYPE).  The layer metadata "LAYER_EN", "LAYER_ES" and 
"LAYER_PT" will never be read and written in the legend section.  It is 
the "wms_title" metadata that is going to be read and written to the 
legend section instead.  This is the code in "legend_template_es.html" 
that says so, see:

[if name=wms_name oper=isnull] use metadata name=LAYER_ES

The "wms_name" metadata is not null so the "LAYER_ES" metadata will not
be used.  But

[if name=wms_name oper=isset] use metadata name=WMS_TITLE will be used 
and the layer name will appear in English in the legend.

Norm








More information about the Chameleon mailing list