-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add phrases for post instruction processing #141
Conversation
@@ -50,6 +50,11 @@ | |||
"destination": "Take the ferry towards {destination}" | |||
} | |||
}, | |||
"phrase": { | |||
"two linked by distance": "{instruction_one} then in {distance} {instruction_two}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the spaces should be removed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any camel casing in here, so I've merged this like this.
two linked by distance
=> twolinkedbydistance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcwhittemore retracting my comment, this should spaces.
bfe967d
to
cfab895
Compare
@mcwhittemore what is your plan for creating two instructions as in |
languages/translations/en.json
Outdated
"phrase": { | ||
"twolinkedbydistance": "{instruction_one} then in {distance} {instruction_two}", | ||
"twolinked": "{instruction_one} then {instruction_two}", | ||
"oneindistance": "In {distance}, {instruction_one}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a comma here? "In 100 meters, turn right" or "In 100 meters turn right"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if you can drop the introductory clause it should be separated from the rest of the sentence by a comma. At least, that is how I remember @lyzidiamond explaining these things to me a few months back, but I'm pretty bad at grammar so I could very well be wrong here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly right @mcwhittemore! "In 100 meters, turn right" is the correct structure.
@bsudekum - I'm doing something like where var osrmTextInstructions = require('osrm-text-instructions');
var osrmEnglish = require('osrm-text-instructions/languages/translations/en.json');
var steps = [ ... ];
var one = osrmTextInstructions.complie('v5', { language: 'en', step: steps[0] }).toLowerCase();
var two = osrmTextInstructions.complie('v5', { language: 'en', step: steps[1] }).toLowerCase();
var opts = {
instruction_one: one,
instruction_two: two
};
var tokenString = osrmEnglish['v5']['phrase']['twolinked'];
var merged = osrmTextInstructions.tokenize(tokenString, opts, 'en'); |
BTW there are some issues with instructions combine this way:
|
Thanks for the feedback @yuryleb!
Ah. Good point. I've updated my example above to use
This is a good idea. I'm going to add |
240f7d6
to
dd25040
Compare
Hmm... it looks like all constants have to be translated before tests will pass. Is this by design? |
How distance value will be rounded before formatting? It will be language-dependent rule/expression (for English always in miles/feet, in kilometers/meters otherwise)? Also I hope final distance value will be rounded to 10 😉 Otherwise I expect "plural" hell with Russian distance units translation and also with some other languages. |
This PR is pushing this question to the down stream user and requiring them to know if they need the plural or non-plural word per the language being used.
Can you explain this a bit more? Are you saying you hope 1.3 meters is rounded to 10 meters? |
I meant there are 3 forms of quantity in Russian not only "one" and "many". For example "In xxx meters do something ..." in Russian:
But if distance will be always rounded to 10, the only one plural form could be used in all languages AFAIK. Also how precise should be the distance? Again for example Garmin navigators have limited set of similar distance instructions: for 100 m, 200 m and so on till 800 m, than for 1 km, 1.5 km (BTW single word numeral in Russian) and 2 km to 8 km. I don't propose to follow exactly this way but some similar distance rounding should be used. And if distance is less than 10 meters (or better 100 meters for drivers), it should be excluded at all. |
23fcac2
to
ab203ef
Compare
@yuryleb - thanks for your feedback. For now I'm going to drop unit translation support from this PR and, as a next step, start looking for a javascript lib that does this well already. My hope is that we find one this is really good. If its missing languages that we support, we can then push that common lib forward rather then writing our own. |
Oh, as a final note, the phrases currently should avoid plurality in translation as they expect the client to pass them a translated distance string. |
- Adds three phrases to the English translations for combining instructions and referencing instruction in relation to distance. - Adds `distance` support to the English `continue.default` and `continue.straight` instructions.
ab203ef
to
805bfb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Opened Project-OSRM/osrm-text-instructions.swift#37 to track a Swift port of this work. |
Since the iOS navigation SDK has historically vended its own phrase format strings, we can copy some of the translations over in Transifex from this resource to this resource. |
There are times when one wants to link two instructions or prefix them with a message. These
phrases
should be translated with the same level of detail as the rest of this project, so I think they should live here. That said, I'm not quite sure how they should be added to the translation files so currently I've only added these toen.json
.This PR adds a
phases
tov5
of the translations along with these new continue phrases.Issue
I think this will close #88.
Tasklist