]> git.openstreetmap.org Git - rails.git/commitdiff
Remove unitTemplate from formatDistance
authorAnton Khorev <tony29@yandex.ru>
Sun, 9 Mar 2025 13:04:42 +0000 (16:04 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 9 Mar 2025 14:16:05 +0000 (17:16 +0300)
Undoes part of a3c45f6ed66862ee394e2a207dedf400acef9b07 to make I18n string references searchable again.

app/assets/javascripts/index/directions.js

index 2d948d4b2eed3e80a6fd004a41c16b2e11911305..a2b383ba0cd5924de0db16edc013eca67cd092dd 100644 (file)
@@ -71,10 +71,13 @@ OSM.Directions = function (map) {
   });
 
   function formatDistance(m) {
-    const unitTemplate = "javascripts.directions.distance_";
-    if (m < 1000) return I18n.t(unitTemplate + "m", { distance: Math.round(m) });
-    if (m < 10000) return I18n.t(unitTemplate + "km", { distance: (m / 1000.0).toFixed(1) });
-    return I18n.t(unitTemplate + "km", { distance: Math.round(m / 1000) });
+    if (m < 1000) {
+      return I18n.t("javascripts.directions.distance_m", { distance: Math.round(m) });
+    } else if (m < 10000) {
+      return I18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) });
+    } else {
+      return I18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) });
+    }
   }
 
   function formatHeight(m) {