Follow up to [17948]: Make the layer switcher translatable too!
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 2 Oct 2009 20:39:47 +0000 (20:39 +0000)
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 2 Oct 2009 20:39:47 +0000 (20:39 +0000)
app/views/layouts/site.html.erb
config/locales/en.yml
public/javascripts/map.js

index 82efdefce4ff0e2e027f5917e5cd736cc8edb585..a1d835dc1f0023331fdd7abc34168099ea546965 100644 (file)
@@ -6,6 +6,15 @@
       var rails_i18n = new Array();
       rails_i18n["layouts.edit_zoom_alert"]    = '<%= escape_javascript(t('layouts.edit_zoom_alert')) %>';
       rails_i18n["layouts.history_zoom_alert"] = '<%= escape_javascript(t('layouts.history_zoom_alert')) %>';
+      // Layer switcher
+      rails_i18n["site.layers.base.mapnik"]        = '<%= escape_javascript(t('site.layers.base.mapnik')) %>';
+      rails_i18n["site.layers.base.osmarender"]    = '<%= escape_javascript(t('site.layers.base.osmarender')) %>';
+      rails_i18n["site.layers.base.cycle_map"]     = '<%= escape_javascript(t('site.layers.base.cycle_map')) %>';
+      rails_i18n["site.layers.base.noname"]        = '<%= escape_javascript(t('site.layers.base.noname')) %>';
+      rails_i18n["site.layers.overlays.maplint"]   = '<%= escape_javascript(t('site.layers.overlays.maplint')) %>';
+      rails_i18n["site.layers.overlays.markers"]   = '<%= escape_javascript(t('site.layers.overlays.markers')) %>';
+      rails_i18n["site.layers.overlays.objects"]   = '<%= escape_javascript(t('site.layers.overlays.objects')) %>';
+      rails_i18n["site.layers.overlays.box_layer"] = '<%= escape_javascript(t('site.layers.overlays.box_layer')) %>';
     </script>
     <%= javascript_include_tag 'prototype' %>
     <%= javascript_include_tag 'site' %>
index 7e096def5e021997a3bc58e08342f5a1aab2cd87..0473e771312e73208727cc170dc35fa4ce97cf1f 100644 (file)
@@ -614,6 +614,17 @@ en:
     delete:
       deleted: "Message deleted"
   site:
+    layers:
+      base:
+        mapnik: Mapnik
+        osmarender: Osmarender
+        cycle_map: Cycle Map
+        noname: NoName
+      overlays:
+        maplint: Maplint
+        markers: Markers
+        objects: Objects
+        box_layer: Box Layer
     index:
       js_1: "You are either using a browser that doesn't support JavaScript, or you have disabled JavaScript."
       js_2: "OpenStreetMap uses JavaScript for its slippy map."
index 4af30f2a105aa6d9b1f3376510c16cc850b3dfc8..2685fc03a5c1712b10483cc0af95a3e26273c9ed 100644 (file)
@@ -36,26 +36,26 @@ function createMap(divName, options) {
       displayProjection: new OpenLayers.Projection("EPSG:4326")
    });
 
-   var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
+   var mapnik = new OpenLayers.Layer.OSM.Mapnik(rails_i18n["site.layers.base.mapnik"], {
       displayOutsideMaxExtent: true,
       wrapDateLine: true
    });
    map.addLayer(mapnik);
 
-   var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
+   var osmarender = new OpenLayers.Layer.OSM.Osmarender(rails_i18n["site.layers.base.osmarender"], {
       displayOutsideMaxExtent: true,
       wrapDateLine: true
    });
    map.addLayer(osmarender);
 
-   var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", {
+   var cyclemap = new OpenLayers.Layer.OSM.CycleMap(rails_i18n["site.layers.base.cycle_map"], {
       displayOutsideMaxExtent: true,
       wrapDateLine: true
    });
    map.addLayer(cyclemap);
 
    var nonamekey = nonamekeys[document.domain];
-   var noname = new OpenLayers.Layer.OSM("NoName", [
+   var noname = new OpenLayers.Layer.OSM(rails_i18n["site.layers.base.noname"], [
       "http://a.tile.cloudmade.com/" + nonamekey + "/3/256/${z}/${x}/${y}.png",
       "http://b.tile.cloudmade.com/" + nonamekey + "/3/256/${z}/${x}/${y}.png",
       "http://c.tile.cloudmade.com/" + nonamekey + "/3/256/${z}/${x}/${y}.png"
@@ -66,7 +66,7 @@ function createMap(divName, options) {
    });
    map.addLayer(noname);
 
-   var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
+   var maplint = new OpenLayers.Layer.OSM.Maplint(rails_i18n["site.layers.overlays.maplint"], {
       displayOutsideMaxExtent: true,
       wrapDateLine: true
    });
@@ -74,7 +74,7 @@ function createMap(divName, options) {
 
    var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
 
-   markers = new OpenLayers.Layer.Markers("Markers", {
+   markers = new OpenLayers.Layer.Markers(rails_i18n["site.layers.overlays.markers"], {
       displayInLayerSwitcher: false,
       numZoomLevels: numZoomLevels,
       maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
@@ -108,7 +108,7 @@ function addMarkerToMap(position, icon, description) {
 }
 
 function addObjectToMap(url, zoom, callback) {
-   var layer = new OpenLayers.Layer.GML("Objects", url, {
+   var layer = new OpenLayers.Layer.GML(rails_i18n["site.layers.overlays.objects"], url, {
       format: OpenLayers.Format.OSM,
       style: {
           strokeColor: "blue",
@@ -154,7 +154,7 @@ function addObjectToMap(url, zoom, callback) {
 function addBoxToMap(boxbounds) {
    if(!vectors) {
      // Be aware that IE requires Vector layers be initialised on page load, and not under deferred script conditions
-     vectors = new OpenLayers.Layer.Vector("Box Layer", {
+     vectors = new OpenLayers.Layer.Vector(rails_i18n["site.layers.overlays.box_layer"], {
         displayInLayerSwitcher: false
      });
      map.addLayer(vectors);