From c2730bcc8b8b66b10a94b4440da2df2ffaaf0c9d Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 2 Dec 2025 06:46:29 +0100 Subject: [PATCH] Integrate i18n support to maplibre based maps --- app/assets/javascripts/dashboard.js | 2 ++ app/assets/javascripts/maplibre.i18n.js | 9 +++++++++ config/locales/en.yml | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 app/assets/javascripts/maplibre.i18n.js diff --git a/app/assets/javascripts/dashboard.js b/app/assets/javascripts/dashboard.js index 04f6c616c..e7a9ae6a0 100644 --- a/app/assets/javascripts/dashboard.js +++ b/app/assets/javascripts/dashboard.js @@ -1,4 +1,5 @@ //= require maplibre.map +//= require maplibre.i18n $(function () { const defaultHomeZoom = 11; @@ -9,6 +10,7 @@ $(function () { container: "map", style: OSM.Mapnik, attributionControl: false, + locale: OSM.MaplibreLocale, center: OSM.home ? [OSM.home.lon, OSM.home.lat] : [0, 0], zoom: OSM.home ? defaultHomeZoom : 0 }); diff --git a/app/assets/javascripts/maplibre.i18n.js b/app/assets/javascripts/maplibre.i18n.js new file mode 100644 index 000000000..5451395f8 --- /dev/null +++ b/app/assets/javascripts/maplibre.i18n.js @@ -0,0 +1,9 @@ +//= require i18n + +OSM.MaplibreLocale = { + "GeolocateControl.FindMyLocation": OSM.i18n.t("javascripts.map.locate.title"), + "GeolocateControl.LocationNotAvailable": OSM.i18n.t("javascripts.map.locate.not_available"), + "NavigationControl.ZoomIn": OSM.i18n.t("javascripts.map.zoom.in"), + "NavigationControl.ZoomOut": OSM.i18n.t("javascripts.map.zoom.out"), + "Popup.Close": OSM.i18n.t("javascripts.map.popup.close") +}; diff --git a/config/locales/en.yml b/config/locales/en.yml index 65a3e6e1f..c82e80a9a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3561,11 +3561,14 @@ en: tooltip: "Legend" tooltip_disabled: "Legend not available for this layer" map: + popup: + close: Close zoom: in: Zoom In out: Zoom Out locate: title: Show My Location + not_available: Location not available metersPopup: one: You are within %{count} meter of this point other: You are within %{count} meters of this point -- 2.39.5