From 6606d8b454bf368023362d6385593a4e6dcc0365 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Sun, 20 Oct 2024 17:37:34 +0200 Subject: [PATCH] use i18next interpolation instead of concatenating strings --- js/control/TrackAnalysis.js | 16 +++++++++++----- locales/en.json | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/js/control/TrackAnalysis.js b/js/control/TrackAnalysis.js index 3b92528a..abcb9276 100644 --- a/js/control/TrackAnalysis.js +++ b/js/control/TrackAnalysis.js @@ -180,13 +180,19 @@ BR.TrackAnalysis = L.Class.extend({ case 'surface': case 'smoothness': if (typeof analysis[tagName][wayTagParts[1]] === 'undefined') { - let formattedName = i18next.t([ - 'sidebar.analysis.data.' + tagName + '.' + wayTagParts[1], - wayTagParts[1], - ]); + let formattedName; + if (tagName.indexOf('maxspeed') === 0) { - formattedName += ' km/h'; + formattedName = i18next.t('sidebar.analysis.data.maxspeed', { + maxspeed: wayTagParts[1], + }); + } else { + formattedName = i18next.t([ + 'sidebar.analysis.data.' + tagName + '.' + wayTagParts[1], + wayTagParts[1], + ]); } + analysis[tagName][wayTagParts[1]] = { formatted_name: formattedName, name: wayTagParts[1], diff --git a/locales/en.json b/locales/en.json index 5ecb5349..309d85ed 100644 --- a/locales/en.json +++ b/locales/en.json @@ -338,7 +338,8 @@ "horrible": "Horrible", "very_horrible": "Very Horrible", "impassable": "Impassable" - } + }, + "maxspeed": "{{maxspeed}} km/h" }, "header": { "highway": "Highway",