From: Tom Hughes Date: Sun, 25 Feb 2018 20:51:11 +0000 (+0000) Subject: Show exit numbers for off ramps in OSRM directions X-Git-Tag: live~3106 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/d8eda6ba03f757d0cd5997b788d660aad2bf2e3c Show exit numbers for off ramps in OSRM directions Fixes #1768 --- diff --git a/app/assets/javascripts/index/directions/osrm.js b/app/assets/javascripts/index/directions/osrm.js index e31c053ef..f2276c11f 100644 --- a/app/assets/javascripts/index/directions/osrm.js +++ b/app/assets/javascripts/index/directions/osrm.js @@ -117,19 +117,14 @@ function OSRMEngine() { instText += I18n.t(template + '_without_exit', { name: name } ); } } else if (step.maneuver.type.match(/on ramp|off ramp/)) { - if (step.destinations) { - if (namedRoad) { - instText += I18n.t(template + '_with_name_and_directions', { name: name, directions: destinations } ); - } else { - instText += I18n.t(template + '_with_directions', { directions: destinations } ); - } - } else { - if (namedRoad) { - instText += I18n.t(template + '_without_exit', { name: name }); - } else { - instText += I18n.t(template + '_without_directions'); - } + var params = {}; + if (step.exits && step.maneuver.type.match(/off ramp/)) params.exit = step.exits; + if (step.destinations) params.directions = step.destinations; + if (namedRoad) params.directions = name; + if (Object.keys(params).length > 0) { + template = template + "_with_" + Object.keys(params).join("_"); } + instText += I18n.t(template, params); } else { instText += I18n.t(template + '_without_exit', { name: name }); } diff --git a/config/locales/en.yml b/config/locales/en.yml index 2550b5b96..fb735cd6c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2329,10 +2329,14 @@ en: instructions: continue_without_exit: Continue on %{name} slight_right_without_exit: Slight right onto %{name} - offramp_right_without_exit: Take the ramp on the right onto %{name} + offramp_right: Take the ramp on the right + offramp_right_with_exit: Take exit %{exit} on the right + offramp_right_with_exit_name: Take exit %{exit} on the right onto %{name} + offramp_right_with_exit_directions: Take exit %{exit} on the right towards %{directions} + offramp_right_with_exit_name_directions: Take exit %{exit} on the right onto %{name}, towards %{directions} + offramp_right_with_name: Take the ramp on the right onto %{name} offramp_right_with_directions: Take the ramp on the right towards %{directions} - offramp_right_with_name_and_directions: Take the ramp on the right onto %{name}, towards %{directions} - offramp_right_without_directions: Take the ramp on the right + offramp_right_with_name_directions: Take the ramp on the right onto %{name}, towards %{directions} onramp_right_without_exit: Turn right on the ramp onto %{name} onramp_right_with_directions: Turn right onto the ramp towards %{directions} onramp_right_with_name_and_directions: Turn right on the ramp onto %{name}, towards %{directions} @@ -2345,10 +2349,14 @@ en: uturn_without_exit: U-turn along %{name} sharp_left_without_exit: Sharp left onto %{name} turn_left_without_exit: Turn left onto %{name} - offramp_left_without_exit: Take the ramp on the left onto %{name} + offramp_left: Take the ramp on the left + offramp_left_with_exit: Take exit %{exit} on the left + offramp_left_with_exit_name: Take exit %{exit} on the left onto %{name} + offramp_left_with_exit_directions: Take exit %{exit} on the left towards %{directions} + offramp_left_with_exit_name_directions: Take exit %{exit} on the left onto %{name}, towards %{directions} + offramp_left_with_name: Take the ramp on the left onto %{name} offramp_left_with_directions: Take the ramp on the left towards %{directions} - offramp_left_with_name_and_directions: Take the ramp on the left onto %{name}, towards %{directions} - offramp_left_without_directions: Take the ramp on the left + offramp_left_with_name_directions: Take the ramp on the left onto %{name}, towards %{directions} onramp_left_without_exit: Turn left on the ramp onto %{name} onramp_left_with_directions: Turn left onto the ramp towards %{directions} onramp_left_with_name_and_directions: Turn left on the ramp onto %{name}, towards %{directions}