From 825468f0d83512150963b8f4b0c787826014c93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bl=C3=A4sta?= Date: Tue, 10 Dec 2024 09:42:43 +0100 Subject: [PATCH] feature: localize draganddrop control --- src/controls/draganddrop.js | 13 +++++++++---- src/loc/en_US.json | 7 ++++++- src/loc/sv_SE.json | 7 ++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/controls/draganddrop.js b/src/controls/draganddrop.js index 09ecdb1b7..3ac1cef25 100644 --- a/src/controls/draganddrop.js +++ b/src/controls/draganddrop.js @@ -11,6 +11,11 @@ const DragAndDrop = function DragAndDrop(options = {}) { let viewer; let map; let legendButton; + const localization = options.localization; + + function localize(key) { + return localization.getStringByKeys({ targetParentKey: 'draganddrop', targetKey: key }); + } if (options.showLegendButton) { const fileInput = InputFile({ @@ -45,8 +50,8 @@ const DragAndDrop = function DragAndDrop(options = {}) { inputEl.value = null; inputEl.click(); }, - text: 'Lägg till från fil', - ariaLabel: 'Lägg till från fil' + text: localize('addFromFile'), + ariaLabel: localize('addFromFile') }); legendButton = El({ @@ -67,8 +72,8 @@ const DragAndDrop = function DragAndDrop(options = {}) { const legend = viewer.getControlByName('legend'); legend.addButtonToTools(legendButton, 'addLayerButton'); } - const groupName = options.groupName || 'egna-lager'; - const groupTitle = options.groupTitle || 'Egna lager'; + const groupName = options.groupName || localize('yourLayersName'); + const groupTitle = options.groupTitle || localize('yourLayersTitle'); const draggable = options.draggable || true; const promptlessRemoval = options.promptlessRemoval !== false; const styleByAttribute = options.styleByAttribute || false; diff --git a/src/loc/en_US.json b/src/loc/en_US.json index 649aea7a4..86d4d98e8 100644 --- a/src/loc/en_US.json +++ b/src/loc/en_US.json @@ -146,5 +146,10 @@ "pointTypeSquare": "Square", "pointTypeMarker": "Marker" } + }, + "draganddrop": { + "addFromFile": "Add from file", + "yourLayersName": "your-layers", + "yourLayersTitle": "Your layers" } -} \ No newline at end of file +} diff --git a/src/loc/sv_SE.json b/src/loc/sv_SE.json index 48a06422e..2ec1cbc81 100644 --- a/src/loc/sv_SE.json +++ b/src/loc/sv_SE.json @@ -147,5 +147,10 @@ "pointTypeSquare": "Fyrkant", "pointTypeMarker": "Markör" } + }, + "draganddrop": { + "addFromFile": "Lägg till från fil", + "yourLayersName": "egna-lager", + "yourLayersTitle": "Egna lager" } -} \ No newline at end of file +}