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 of zoom, geoposition, about and home control #2091

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
7 changes: 6 additions & 1 deletion src/controls/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const About = function About(options = {}) {
buttonText,
target
} = options;
const localization = options.localization;

function localize(key) {
return localization.getStringByKeys({ targetParentKey: 'about', targetKey: key });
}
const {
content = '<p></p>',
icon = '#ic_help_outline_24px',
placement = ['menu'],
title = 'Om kartan',
title = localize('title'),
style
} = options;

Expand Down
7 changes: 6 additions & 1 deletion src/controls/geoposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const Geoposition = function Geoposition(options = {}) {
let positionButton;
let markerOverlay;
let geolocation;
const localization = options.localization;

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

const centerPosition = () => {
if (geolocation.getTracking()) {
Expand Down Expand Up @@ -137,7 +142,7 @@ const Geoposition = function Geoposition(options = {}) {
toggleState();
},
icon: geolocationIcon,
tooltipText: 'Visa din nuvarande position i kartan',
tooltipText: localize('positionButtonTooltip'),
tooltipPlacement: 'east',
methods: {
active: onActive,
Expand Down
7 changes: 6 additions & 1 deletion src/controls/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const Home = function Home(options = {}) {

let viewer;
let homeButton;
const localization = options.localization;

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

const zoomToHome = function zoomToHome() {
viewer.getMap().getView().fit(extent, { duration: 1000 });
Expand All @@ -37,7 +42,7 @@ const Home = function Home(options = {}) {
zoomToHome();
},
icon: '#ic_home_24px',
tooltipText: 'Zooma till hela kartan',
tooltipText: localize('zoomHomeButtonTooltip'),
tooltipPlacement: 'east'
});
},
Expand Down
9 changes: 7 additions & 2 deletions src/controls/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const Zoom = function Zoom(options = {}) {
let viewer;
let zoomIn;
let zoomOut;
const localization = options.localization;

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

const zoomByDelta = function zoomByDelta(deltaValue) {
const map = viewer.getMap();
Expand Down Expand Up @@ -43,7 +48,7 @@ const Zoom = function Zoom(options = {}) {
zoomByDelta(delta);
},
icon: '#ic_add_24px',
tooltipText: 'Zooma in i kartan',
tooltipText: localize('zoomInButtonTooltip'),
tooltipPlacement: 'east'
});
zoomOut = Button({
Expand All @@ -52,7 +57,7 @@ const Zoom = function Zoom(options = {}) {
zoomByDelta(-delta);
},
icon: '#ic_remove_24px',
tooltipText: 'Zooma ut i kartan',
tooltipText: localize('zoomOutButtonTooltip'),
tooltipPlacement: 'east'
});
},
Expand Down
14 changes: 14 additions & 0 deletions src/loc/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,21 @@
"drawSquare": "Square",
"drawCircle": "Circle",
"drawFreehand": "Freehand"
},
"zoom": {
"zoomInButtonTooltip": "Zoom into the map",
"zoomOutButtonTooltip": "Zoom out in the map"
},
"home": {
"zoomHomeButtonTooltip": "Zoom to the entire map"
},
"geoposition": {
"positionButtonTooltip": "Show your current position on the map"
},
"about": {
"title": "About the map"
}

},
"style": {
"drawStyles": {
Expand Down
14 changes: 13 additions & 1 deletion src/loc/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,20 @@
"drawSquare": "Fyrkant",
"drawCircle": "Cirkel",
"drawFreehand": "Frihand"
},
"zoom": {
"zoomInButtonTooltip": "Zooma in i kartan",
"zoomOutButtonTooltip": "Zooma ut i kartan"
},
"home": {
"zoomHomeButtonTooltip": "Zooma till hela kartan"
},
"geoposition": {
"positionButtonTooltip": "Visa din nuvarande position i kartan"
},
"about": {
"title": "Om kartan"
}

},
"style": {
"drawStyles": {
Expand Down
Loading