From 8a66a816f77b33f8eb526f78915a5046e630aded Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 18 Jun 2020 18:00:00 +0000 Subject: [PATCH 1/4] Run `yarn lint`, `yarn prettier` and `yarn build i18next` 0d6cd61 was still missing some style fixes, making `yarn` touch unrelated files on a subsequent `git commit`. --- js/index.js | 2 +- js/plugin/RouteLoaderConverter.js | 2 +- locales/en.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 069bc4b..cc19ee7 100644 --- a/js/index.js +++ b/js/index.js @@ -305,7 +305,7 @@ BR.tracksLoader(map, layersControl, routing); - BR.routeLoader(map, layersControl, routing,pois); + BR.routeLoader(map, layersControl, routing, pois); pois.addTo(map); routingPathQuality.addTo(map); diff --git a/js/plugin/RouteLoaderConverter.js b/js/plugin/RouteLoaderConverter.js index 201bd9f..ce3c278 100644 --- a/js/plugin/RouteLoaderConverter.js +++ b/js/plugin/RouteLoaderConverter.js @@ -250,7 +250,7 @@ BR.routeLoader = function(map, layersControl, routing, pois) { if (!this._options.format) this._options.format = trackFile.name.split('.').pop(); - const reader = new FileReader(); + var reader = new FileReader(); reader.onload = L.bind(this.processFile, this); reader.readAsText(trackFile); diff --git a/locales/en.json b/locales/en.json index 56573bf..da76e6e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -249,7 +249,6 @@ "explainpoi": "(show waypoints as POI's)", "explaintracklayer": "(show Track as separate Layer)", "file": "Trackfile", - "fromext": "from file extension", "fuzziness": "fuzzines", "pleasewait": "Please wait!", "showpois": "POI's", From f2dd3b95a4da209493111fac7ca9ebf084efbf4d Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Fri, 19 Jun 2020 18:00:00 +0000 Subject: [PATCH 2/4] Add warning regarding `yarn build i18next` / `gulp i18next` Also mention what is done by maintainers. --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1ef80ca..bec8064 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,9 +48,9 @@ docker-compose up serve ### How internationalization works -BRouter is translated using [i18next](https://www.i18next.com/) library, via command `gulp i18next`. It extracts translatable elements into `locales/en.json` file (English version). +BRouter is translated using [i18next](https://www.i18next.com/) library, via command `gulp i18next`. It extracts translatable elements into `locales/en.json` file (English version). (Note that unused translation keys or keys not referenced in `keys.js` might get removed automatically. Make sure to commit any changes first before running this, and only amend the previous commit after checking the diff carefully.) -As soon as this file is modified, it must be uploaded to Transifex (manually) with the command `yarn push-transifex`. +As soon as this file is modified, it must be uploaded by the maintainers to Transifex (manually) with the command `yarn push-transifex`. Anyone can then translate BRouter directly on [Transifex](https://www.transifex.com/openstreetmap/brouter-web/) platform. From e3a9f6206f300f8a2bb219c29849e2d03d69666c Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Sat, 20 Jun 2020 18:00:00 +0000 Subject: [PATCH 3/4] Switch to next tab with Shift+T shortcut even if tab is currently closed Often users can remember what the recently opened tab was, so we can switch to and open the next tab immediately, saving one keypress. There is a dedicated shortcut (T) for only opening a tab, after all. While the previous behavior for Shift+T (open tab without switching to next if currently closed) was by intention, user testing found that the new approach might be more desirable. --- js/plugin/Sidebar.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/plugin/Sidebar.js b/js/plugin/Sidebar.js index 0199906..36269f2 100644 --- a/js/plugin/Sidebar.js +++ b/js/plugin/Sidebar.js @@ -123,24 +123,24 @@ BR.Sidebar = L.Control.Sidebar.extend({ _keydownListener: function(e) { if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggleTabs) { if ($('#sidebarTabs > ul > li[class=active]').length) { - // sidebar is currently open - if (e.shiftKey) { - // try to find next tab - var nextTab = $('#sidebarTabs > ul > li[class=active] ~ li:not([hidden]) > a'); - if (!nextTab.length) { - // wrap around to first tab - nextTab = $('#sidebarTabs > ul > li:not([hidden]) > a'); - } - // switch to next or first tab - this.open(nextTab.attr('href').slice(1)); - } else { - // close current tab + // sidebar is currently open, close current tab + if (!e.shiftKey) { this.close(); } } else { // sidebar is currently closed, open recent or default tab this.open(this.recentTab); } + if (e.shiftKey) { + // try to find next tab + var nextTab = $('#sidebarTabs > ul > li[class=active] ~ li:not([hidden]) > a'); + if (!nextTab.length) { + // wrap around to first tab + nextTab = $('#sidebarTabs > ul > li:not([hidden]) > a'); + } + // switch to next or first tab + this.open(nextTab.attr('href').slice(1)); + } } } }); From 09f987ea07cfbeef4e95de3f6f69735ea147fad6 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Sun, 21 Jun 2020 18:00:00 +0000 Subject: [PATCH 4/4] Combine and reuse translations for keyboard shortcuts Using i18next's "nesting" and "interpolation" features should reduce the overall number of strings to translate, as well as provide a standardized pattern for shortcut tooltips (if applicable). Note that this approach is still allowing for flexibility regarding differently structured sentences in each language. Resolves #315 --- index.html | 52 +++++++++++++++++++---- js/Map.js | 6 +-- js/control/RoutingOptions.js | 2 +- js/index.js | 32 ++++++++++----- js/plugin/POIMarkers.js | 7 +++- js/plugin/RoutingPathQuality.js | 6 +-- js/plugin/stravaSegments.js | 4 +- locales/en.json | 73 ++++++++++++++++++--------------- locales/keys.js | 40 ++++++++++++++++-- 9 files changed, 156 insertions(+), 66 deletions(-) diff --git a/index.html b/index.html index f5df4de..96d26d7 100644 --- a/index.html +++ b/index.html @@ -61,7 +61,8 @@ role="button" aria-haspopup="true" aria-expanded="false" - data-i18n="[title]navbar.export-tooltip" + data-i18n="[title]keyboard.generic-shortcut" + data-i18n-options='{ "action": "$t(navbar.export-tooltip)", "key": "X" }' title="Export route" > @@ -79,6 +80,12 @@ aria-haspopup="true" aria-expanded="false" data-i18n="[title]navbar.load.tooltip" + data-i18n-options='{ + "tracksAction": "$t(navbar.load.tracks)", + "tracksKey": "O", + "nogosAction": "$t(navbar.load.nogos)", + "nogosKey": "$t(keyboard.shift)+O" + }' title="Load route" > @@ -113,7 +120,8 @@