]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/browse/start.rjs
Nuked 'browse.start_rjs.unable_to_load' and replaced it with
[rails.git] / app / views / browse / start.rjs
index c5247066e7e6143c5dcda7053c03652fca1a2e97..4df6148473b72d71fa747eea3018d07e099129c1 100644 (file)
@@ -131,7 +131,7 @@ page << <<EOJ
     var div = document.createElement("div");
 
     var p = document.createElement("p");
-    p.appendChild(document.createTextNode("#{I18n.t('browse.start_rjs.loaded_an_area')} " + browseFeatureList.length + " #{I18n.t('browse.start_rjs.browsers')}"));
+    p.appendChild(document.createTextNode(i18n_js("#{I18n.t('browse.start_rjs.loaded_an_area_with_num_features', :num_features => '{{num_features}}')}", { num_features: browseFeatureList.length })));
     div.appendChild(p);
 
     var input = document.createElement("input");
@@ -186,8 +186,8 @@ page << <<EOJ
     var projected = bounds.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
     var size = projected.getWidth() * projected.getHeight();
 
-    if (size > 0.25) {
-      setStatus("#{I18n.t('browse.start_rjs.unable_to_load')} " + size + " #{I18n.t('browse.start_rjs.must_be_smaller')}");
+    if (size > #{APP_CONFIG['max_request_area']}) {
+      setStatus(i18n_js("#{I18n.t('browse.start_rjs.unable_to_load_size', :bbox_size => '{{bbox_size}}', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size }));
     } else {
       loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX());
     }
@@ -486,6 +486,22 @@ page << <<EOJ
     }
   }
 
+  /*
+   This is a hack so that we can interpolate JavaScript variables in
+   translation strings from Ruby, doing the string replacement
+   client-side instead of on the server.
+  */
+  function i18n_js(string, keys) {
+    for (var key in keys) {
+      var re_key = '\{\{' + key + '\}\}';
+      var re = new RegExp(re_key, "g");
+
+      string = string.replace(re, keys[key]);
+    }
+
+    return string;
+  } 
+
   function setStatus(status) {
     $("browse_status").innerHTML = status;
     $("browse_status").style.display = "block";