Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: localize externalurl control #2104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/controls/externalurl/externalurlSeveralButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Component, Element as El, Button, dom } from '../../ui';
import replacer from '../../utils/replacer';

const externalurlSeveralButtons = function externalurlSeveralButtons(options = {}) {
const mainbuttonTooltipText = options.tooltipText || 'Visa kartan i en extern karttjänst';
const localization = options.localization;

function localize(key) {
return localization.getStringByKeys({ targetParentKey: 'externalurl', targetKey: key });
}

const mainbuttonTooltipText = options.tooltipText || localize('tooltipText');
const links = options.links;
const hasValidMethod = links.some(link => link.method !== 'none');
let map;
Expand Down Expand Up @@ -79,7 +85,7 @@ const externalurlSeveralButtons = function externalurlSeveralButtons(options = {
});
buttons.push(externalUrlMainButton);
links.forEach((link) => {
const tooltipText = link.tooltipText;
const tooltipText = link.tooltipText ? link.tooltipText : localize('linkTooltipText');
const buttonImage = link.buttonImage || '#fa-external-link';
const subButton = Button({
cls: `o-measure-length padding-small ${subButtoncls} icon-smaller round light box-shadow hidden`,
Expand Down
10 changes: 8 additions & 2 deletions src/controls/externalurl/externalurlSingleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ import { Component, Element as El, Button, dom } from '../../ui';
import replacer from '../../utils/replacer';

const ExternalurlSingleButton = function ExternalurlSingleButton(options = {}) {
const localization = options.localization;

function localize(key) {
return localization.getStringByKeys({ targetParentKey: 'externalurl', targetKey: key });
}

let map;
let viewer;
let exUrlElement;
let exUrlBtn;
let target;
const buttons = [];
const tooltip = options.links[0].tooltipText || options.tooltipText || 'Visa kartan i en extern karttjänst';
const tooltip = options.links[0].tooltipText || options.tooltipText || localize('tooltipText');
const buttonImage = options.links[0].buttonImage || '#ic_baseline_link_24px';
const url = options.links[0].url;
const method = options.links[0].method;
const destinationProjection = options.links[0].projection || 'EPSG:3857';

function onClick() {
if (!url) {
alert('No URL is specified in the configurations');
alert(localize('noUrl'));
return;
}

Expand Down
17 changes: 11 additions & 6 deletions src/loc/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@
"drawSquare": "Square",
"drawCircle": "Circle",
"drawFreehand": "Freehand"
},
"bookmarks": {
"title": "Bookmarks",
"close": "Close",
"bookmarkLabel": "Bookmark for"
},
"externalurl": {
"tooltipText": "Display the map in an external map service",
"noUrl": "No URL is specified in the configuration",
"linkTooltipText": "Open link"
}
},
"style": {
Expand Down Expand Up @@ -146,10 +156,5 @@
"pointTypeSquare": "Square",
"pointTypeMarker": "Marker"
}
},
"bookmarks": {
"title": "Bookmarks",
"close": "Close",
"bookmarkLabel": "Bookmark for"
}
}
}
18 changes: 11 additions & 7 deletions src/loc/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,17 @@
"drawSquare": "Fyrkant",
"drawCircle": "Cirkel",
"drawFreehand": "Frihand"
},
"bookmarks": {
"title": "Bokmärken",
"close": "Stäng",
"bookmarkLabel": "Bokmärke för"
},
"externalurl": {
"tooltipText": "Visa kartan i en extern karttjänst",
"noUrl": "Ingen URL är angiven i konfigurationen",
"linkTooltipText": "Öppna länk"
}

},
"style": {
"drawStyles": {
Expand Down Expand Up @@ -147,10 +156,5 @@
"pointTypeSquare": "Fyrkant",
"pointTypeMarker": "Markör"
}
},
"bookmarks": {
"title": "Bokmärken",
"close": "Stäng",
"bookmarkLabel": "Bokmärke för"
}
}
}
Loading