From f23e3751b5783188fb00503eb14ffc162eaf341f Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Mon, 1 Jun 2020 18:00:00 +0000 Subject: [PATCH] Allow translation of the search field placeholder text It was not translated before, since the string was coming from an external dependency. --- js/plugin/Search.js | 9 +++++++++ locales/en.json | 1 + 2 files changed, 10 insertions(+) diff --git a/js/plugin/Search.js b/js/plugin/Search.js index b0f20e0..7e0cabb 100644 --- a/js/plugin/Search.js +++ b/js/plugin/Search.js @@ -9,6 +9,15 @@ BR.Search = L.Control.Geocoder.extend({ position: 'topleft' }, + initialize: function(options) { + L.Control.Geocoder.prototype.initialize.call(this, options); + L.setOptions(this, { + // i18next.t will only return 'undefined' if it is called in a static context + // (e.g. when added directly to "options:" above), so we have to call it here + placeholder: i18next.t('map.geocoder-placeholder') + }); + }, + markGeocode: function(result) { this._map.fitBounds(result.geocode.bbox, { maxZoom: 17 diff --git a/locales/en.json b/locales/en.json index 7208818..1399b44 100644 --- a/locales/en.json +++ b/locales/en.json @@ -91,6 +91,7 @@ "draw-route-start": "Draw route (D key)", "draw-route-stop": "Stop drawing route (ESC key)", "enter-poi-name": "Enter Point of Interest name", + "geocoder-placeholder": "Search…", "hikebike-hillshading": "Hillshading", "hiking": "Hiking", "layer": {