From 78170f8fe9a518da04ca7d3252a22f0b0b07f8a3 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 1 Mar 2018 00:58:53 -0500 Subject: [PATCH] Improve hint text to aid in localization - change the "Up to {num} ways" to "Up to 2 ways" (we don't plan to go above 2 for now) - enumerate all the turn types No/Only/Allowed x Left/Right/Straight/U - Add a line for "Click for" to let user know they can click to toggle see https://github.com/openstreetmap/iD/pull/4768#pullrequestreview-100256196 --- data/core.yaml | 28 ++++++++++++------------- dist/locales/en.json | 28 ++++++++++++------------- modules/ui/fields/restrictions.js | 35 ++++++++++++++----------------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index be8cb7a76..4d487fa0d 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -229,20 +229,22 @@ en: via: Via via_node_only: "Node only" via_up_to_one: "Up to 1 way" - via_up_to_multiple: "Up to {num} ways" + via_up_to_two: "Up to 2 ways" help: - no: NO - only: ONLY - allowed: Allowed indirect: "(indirect)" turn: - left_turn: Left Turn - right_turn: Right Turn - u_turn: U-Turn - straight_on: Straight On - no_turn_string: "{no} {turn} {indirect}" - only_turn_string: "{only} {turn} {indirect}" - allowed_turn_string: "{turn} {allowed} {indirect}" + no_left_turn: "NO Left Turn {indirect}" + no_right_turn: "NO Right Turn {indirect}" + no_u_turn: "NO U-Turn {indirect}" + no_straight_on: "NO Straight On {indirect}" + only_left_turn: "ONLY Left Turn {indirect}" + only_right_turn: "ONLY Right Turn {indirect}" + only_u_turn: "ONLY U-Turn {indirect}" + only_straight_on: "ONLY Straight On {indirect}" + allowed_left_turn: "Left Turn Allowed {indirect}" + allowed_right_turn: "Right Turn Allowed {indirect}" + allowed_u_turn: "U-Turn Allowed {indirect}" + allowed_straight_on: "Straight On Allowed {indirect}" from: FROM via: VIA to: TO @@ -251,9 +253,7 @@ en: via_names: "{via} {viaNames}" select_from: "Click to select a {from} segment" select_from_name: "Click to select {from} {fromName}" - toggle: Click to toggle turn restrictions. - toggle_on: 'Click to add a "{restriction}" restriction.' - toggle_off: 'Click to remove the "{restriction}" restriction.' + toggle: "Click for \"{turn}\"" undo: tooltip: "Undo: {action}" nothing: Nothing to undo. diff --git a/dist/locales/en.json b/dist/locales/en.json index 14d209991..bf5fe30d0 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -298,22 +298,24 @@ "via": "Via", "via_node_only": "Node only", "via_up_to_one": "Up to 1 way", - "via_up_to_multiple": "Up to {num} ways" + "via_up_to_two": "Up to 2 ways" }, "help": { - "no": "NO", - "only": "ONLY", - "allowed": "Allowed", "indirect": "(indirect)", "turn": { - "left_turn": "Left Turn", - "right_turn": "Right Turn", - "u_turn": "U-Turn", - "straight_on": "Straight On" + "no_left_turn": "NO Left Turn {indirect}", + "no_right_turn": "NO Right Turn {indirect}", + "no_u_turn": "NO U-Turn {indirect}", + "no_straight_on": "NO Straight On {indirect}", + "only_left_turn": "ONLY Left Turn {indirect}", + "only_right_turn": "ONLY Right Turn {indirect}", + "only_u_turn": "ONLY U-Turn {indirect}", + "only_straight_on": "ONLY Straight On {indirect}", + "allowed_left_turn": "Left Turn Allowed {indirect}", + "allowed_right_turn": "Right Turn Allowed {indirect}", + "allowed_u_turn": "U-Turn Allowed {indirect}", + "allowed_straight_on": "Straight On Allowed {indirect}" }, - "no_turn_string": "{no} {turn} {indirect}", - "only_turn_string": "{only} {turn} {indirect}", - "allowed_turn_string": "{turn} {allowed} {indirect}", "from": "FROM", "via": "VIA", "to": "TO", @@ -322,9 +324,7 @@ "via_names": "{via} {viaNames}", "select_from": "Click to select a {from} segment", "select_from_name": "Click to select {from} {fromName}", - "toggle": "Click to toggle turn restrictions.", - "toggle_on": "Click to add a \"{restriction}\" restriction.", - "toggle_off": "Click to remove the \"{restriction}\" restriction." + "toggle": "Click for \"{turn}\"" } }, "undo": { diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 97b10a03c..0905d5b1e 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -499,35 +499,26 @@ export function uiFieldRestrictions(field, context) { var restrictionType = osmInferRestriction(vgraph, datum, projection); var turnType = restrictionType.replace(/^(only|no)\_/, ''); var indirect = (datum.direct === false ? t('restriction.help.indirect') : ''); - var klass, turnHtml; + var klass, turnText, nextText; if (datum.no) { klass = 'restrict'; - turnHtml = t('restriction.help.no_turn_string', { - no: t('restriction.help.no'), - turn: t('restriction.help.turn.' + turnType), - indirect: indirect - }); + turnText = t('restriction.help.turn.no_' + turnType, { indirect: indirect }); + nextText = t('restriction.help.turn.only_' + turnType, { indirect: '' }); } else if (datum.only) { klass = 'only'; - turnHtml = t('restriction.help.only_turn_string', { - only: t('restriction.help.only'), - turn: t('restriction.help.turn.' + turnType), - indirect: indirect - }); + turnText = t('restriction.help.turn.only_' + turnType, { indirect: indirect }); + nextText = t('restriction.help.turn.allowed_' + turnType, { indirect: '' }); } else { klass = 'allow'; - turnHtml = t('restriction.help.allowed_turn_string', { - allowed: t('restriction.help.allowed'), - turn: t('restriction.help.turn.' + turnType), - indirect: indirect - }); + turnText = t('restriction.help.turn.allowed_' + turnType, { indirect: indirect }); + nextText = t('restriction.help.turn.no_' + turnType, { indirect: '' }); } help - .append('div') // Turn Description + .append('div') // "NO Right Turn (indirect)" .attr('class', 'qualifier ' + klass) - .html(turnHtml); + .text(turnText); help .append('div') // "FROM {fromName} TO {toName}" @@ -555,6 +546,12 @@ export function uiFieldRestrictions(field, context) { })); } + if (!indirect) { + help + .append('div') // Click for "No Right Turn" + .text(t('restriction.help.toggle', { turn: nextText.trim() })); + } + highlightPathsFrom(null); var alongIDs = datum.path.slice(); surface.selectAll(utilEntitySelector(alongIDs)) @@ -607,7 +604,7 @@ export function uiFieldRestrictions(field, context) { function displayMaxVia(maxVia) { return maxVia === 0 ? t('restriction.controls.via_node_only') : maxVia === 1 ? t('restriction.controls.via_up_to_one') - : t('restriction.controls.via_up_to_multiple', { num: maxVia }); + : t('restriction.controls.via_up_to_two'); }