Canadian-Geospatial-Platform / geoview

Canadian Geospatial Platform Viewer / Visualiseur de la Plateforme Géospatiale Canadienne
Other
22 stars 32 forks source link

[BUG] French config is overridden by English values #2284

Closed jaredkinger closed 3 months ago

jaredkinger commented 3 months ago

Is there an existing issue for this?

Current Behavior

When using a config that has localized strings in both EN and FR and the data-lang="fr" attribute set on the map element the layerName and metadataAccessPath use the English values and ignore the French values that have been set. The suportedLanguages property also creates a schema error.

Expected Behavior

When supporting both languages and the data-lang="fr" attribute is set on the map element, the French values from the config should be used.

Steps To Reproduce

  1. Go here: https://wordpress.dev.geo.ca/wp-content/geoview/examples/translation.html
  2. Notice that both the French and the English map have the same layer names and class names in the legend.
  3. View the console and the suportedLanguages property will throw a schema error
  4. View the Network tab in the inspector and look at the Fetch/XHR calls you will see they point to the EN metadataAccessPath values and not the FR values

Anything else?

The ConfigValidation hardcodes the value of suportedLanguages to only include English on lines 190 and 203 instead of using the suportedLanguages value from the config.

I'd also recommend changing "suportedLanguages" to "supportedLanguages" for proper spelling of supported.

Config from example: 3.json

EN Mapserver: https://maps-cartes.services.geo.ca/server2_serveur2/rest/services/StatCan/cd_socioeconomic_variables_2016_en/MapServer

FR Mapserver: https://maps-cartes.services.geo.ca/server2_serveur2/rest/services/StatCan/cd_socioeconomic_variables_2016_fr/MapServer