Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor for more data-driven approach #27

Merged
merged 7 commits into from
Oct 18, 2016

Conversation

freenerd
Copy link
Member

@freenerd freenerd commented Oct 5, 2016

Improves #23
Fixes #6
Ref #19 #24 #14 #8

This makes natural language translations possible and implementations in other programming languages easier on the cost of blowing up the instructions.json.

Next:

  • @bsudekum @1ec5 can you have a look?
  • Fix tests for rotary/roundabout (we need to incorporate the nesting here as well)
  • 🎉

This makes translations possible and implementations in other languages
easier on the cost of blowing up the instructions.json
@freenerd freenerd mentioned this pull request Oct 5, 2016
Copy link
Member

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple nits but overall looks good.

default:
case 'rotary':
case 'roundabout':
if (type === 'rotary' || type === 'roundabout') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement is redundant to the cases we're in.

.replace('{destination}', (step.destinations || '').split(',')[0])
.replace('{exit_number}', ordinalize(step.maneuver.exit || 1))
.replace('{rotary_name}', step.rotary_name)
.replace('{laneInstruction}', laneInstruction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the tokens use train_case, but this one uses camelCase.

"destination": "Continue straight towards {destination}"
},
"left": {
"default": "{laneInstruction} to turn left",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purpose of minimizing translation cost, it may be desirable at some point to refactor this so that there would literally be a string {laneInstruction} to {instruction}. I'm not aware of any languages that would need more granularity in this case, but I could be wrong.

"sharp right": {
"default": "Take a sharp right",
"name": "Take a sharp right onto {way_name}",
"destination": "Take a sharp right towards {way_name}"
Copy link

@bsudekum bsudekum Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be name?

"defaultInstruction": "Continue {modifier}[ onto {way_name}]"
"default": {
"default": "Continue {modifier}",
"name": "Continue {modifier} onto {way_name}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it impossible to have a destination here?

@bsudekum
Copy link

bsudekum commented Oct 5, 2016

Some other thoughts:

  • we should add a test that verifies that each type has the 3 required keys
  • Should the key name be renamed to way_name so it corresponds to the template we're replacing? {way_name}? Downside here is that _ in keys is a little icky looking to me, upside is it's more clear.

I think there are some good moves here going on but with this PR we're 3x'ing the instruction.json and only reducing index.js by a couple of lines.

@freenerd
Copy link
Member Author

freenerd commented Oct 5, 2016

Incorporated all inline comments in f54c828

we should add a test that verifies that each type has the 3 required keys

Yes. It feels like the test fixtures need to eventually look similar to the instructions.json. I might also want to generate them programatically then. Specifically lanes, rotary and roundabouts will need work.

Should the key name be renamed to way_name so it corresponds to the template we're replacing?

👍

@1ec5
Copy link
Member

1ec5 commented Oct 5, 2016

we're 3x'ing the instruction.json and only reducing index.js by a couple of lines.

In general, that's to be expected with making anything more data-driven, although I've suggested a change above that would reduce the string bloat a bit.

@freenerd freenerd force-pushed the destinations-without-template branch from f54c828 to f9b110d Compare October 7, 2016 16:17
@freenerd freenerd force-pushed the destinations-without-template branch from f9b110d to be80c99 Compare October 17, 2016 15:45
@freenerd
Copy link
Member Author

Some more changes:

"name": "{lane_instruction} to make a U-turn onto {way_name}",
"destination": "{lane_instruction} to make a U-turn towards {destination}"
},
"lane_types": {
"xo": "Keep right",
"ox": "Keep left",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move these to .constants

@1ec5
Copy link
Member

1ec5 commented Oct 17, 2016

On iOS, I was planning to use the Mapbox iOS/macOS SDK's MGLCompassDirectionFormatter class for compass directions (which would be localized along with the SDK), but this is a reasonable approach.

@freenerd
Copy link
Member Author

Consolidated use lane as well.

I think we are good here now, next step is merging, releasing a new version, integrating and then continue to fix things. Will do that tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants