From 09f987ea07cfbeef4e95de3f6f69735ea147fad6 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Sun, 21 Jun 2020 18:00:00 +0000 Subject: [PATCH] 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 @@