Skip to content

Commit

Permalink
feature: localize draganddrop control
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyblasta committed Dec 10, 2024
1 parent 1872642 commit 825468f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/controls/draganddrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand All @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/loc/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,10 @@
"pointTypeSquare": "Square",
"pointTypeMarker": "Marker"
}
},
"draganddrop": {
"addFromFile": "Add from file",
"yourLayersName": "your-layers",
"yourLayersTitle": "Your layers"
}
}
}
7 changes: 6 additions & 1 deletion src/loc/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@
"pointTypeSquare": "Fyrkant",
"pointTypeMarker": "Markör"
}
},
"draganddrop": {
"addFromFile": "Lägg till från fil",
"yourLayersName": "egna-lager",
"yourLayersTitle": "Egna lager"
}
}
}

0 comments on commit 825468f

Please sign in to comment.