Skip to content

Commit

Permalink
use i18next interpolation instead of concatenating strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaschen committed Oct 20, 2024
1 parent bb3bfba commit 6606d8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions js/control/TrackAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@
"horrible": "Horrible",
"very_horrible": "Very Horrible",
"impassable": "Impassable"
}
},
"maxspeed": "{{maxspeed}} km/h"
},
"header": {
"highway": "Highway",
Expand Down

0 comments on commit 6606d8b

Please sign in to comment.