Skip to content

Add ceremonial name handling #129

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

Merged
merged 6 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,18 @@ module.exports = function(version, _options) {
}
name = name.replace(' (' + step.ref + ')', '');

if (name && ref && name !== ref) {
// In attempt to avoid using the highway name of a way,
// check and see if the step has a class which should signal
// the ref should be used instead of the name.
var wayMotorway = false;
if (options && options.classes) {
wayMotorway = options.classes.some((className) => ['motorway'].indexOf(className) > -1);
}

if (name && ref && name !== ref && !wayMotorway) {
wayName = name + ' (' + ref + ')';
} else if (name && ref && wayMotorway && (/\d/).test(ref)) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: drop the extra parentheses around the regular expression.

Copy link
Author

Choose a reason for hiding this comment

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

The linter for this project actually requires them 😅

wayName = ref;
} else if (!name && ref) {
wayName = ref;
} else {
Expand Down
2 changes: 1 addition & 1 deletion languages/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion languages/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@
}
}
}
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "left"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Links weiterfahren auf Cool highway",
"en": "Continue left onto Cool highway",
"es": "Continua izquierda en Cool highway",
"fr": "Continuer à gauche sur Cool highway",
"id": "Terus kiri ke Cool highway",
"nl": "Ga links naar Cool highway",
"pl": "Kontynuuj lewo na Cool highway",
"ru": "Двигайтесь налево по Cool highway",
"sv": "Fortsätt vänster in på Cool highway",
"vi": "Chạy tiếp bên trái trên Cool highway",
"zh-Hans": "继续向左,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_right.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "right"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Rechts weiterfahren auf Cool highway",
"en": "Continue right onto Cool highway",
"es": "Continua derecha en Cool highway",
"fr": "Continuer à droite sur Cool highway",
"id": "Terus kanan ke Cool highway",
"nl": "Ga rechts naar Cool highway",
"pl": "Kontynuuj prawo na Cool highway",
"ru": "Двигайтесь направо по Cool highway",
"sv": "Fortsätt höger in på Cool highway",
"vi": "Chạy tiếp bên phải trên Cool highway",
"zh-Hans": "继续向右,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_sharp left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp left"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Scharf links weiterfahren auf Cool highway",
"en": "Continue sharp left onto Cool highway",
"es": "Continua cerrada a la izquierda en Cool highway",
"fr": "Continuer franchement à gauche sur Cool highway",
"id": "Terus tajam kiri ke Cool highway",
"nl": "Ga linksaf naar Cool highway",
"pl": "Kontynuuj ostro w lewo na Cool highway",
"ru": "Двигайтесь налево по Cool highway",
"sv": "Fortsätt skarp vänster in på Cool highway",
"vi": "Chạy tiếp bên trái gắt trên Cool highway",
"zh-Hans": "继续向左,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_sharp right.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "sharp right"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Scharf rechts weiterfahren auf Cool highway",
"en": "Continue sharp right onto Cool highway",
"es": "Continua cerrada a la derecha en Cool highway",
"fr": "Continuer franchement à droite sur Cool highway",
"id": "Terus tajam kanan ke Cool highway",
"nl": "Ga rechtsaf naar Cool highway",
"pl": "Kontynuuj ostro w prawo na Cool highway",
"ru": "Двигайтесь направо по Cool highway",
"sv": "Fortsätt skarp höger in på Cool highway",
"vi": "Chạy tiếp bên phải gắt trên Cool highway",
"zh-Hans": "继续向右,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_slight left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight left"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Leicht links weiter auf Cool highway",
"en": "Continue slightly left onto Cool highway",
"es": "Continua ligeramente a la izquierda en Cool highway",
"fr": "Continuer légèrement à gauche sur Cool highway",
"id": "Tetap agak di kiri ke Cool highway",
"nl": "Links aanhouden naar Cool highway",
"pl": "Kontynuuj łagodnie w lewo na Cool highway",
"ru": "Плавно поверните налево на Cool highway",
"sv": "Fortsätt med lätt vänstersväng in på Cool highway",
"vi": "Nghiêng về bên trái vào Cool highway",
"zh-Hans": "继续向左,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "slight right"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Leicht rechts weiter auf Cool highway",
"en": "Continue slightly right onto Cool highway",
"es": "Continua ligeramente a la derecha en Cool highway",
"fr": "Continuer légèrement à droite sur Cool highway",
"id": "Tetap agak di kanan ke Cool highway",
"nl": "Rechts aanhouden naar Cool highway",
"pl": "Kontynuuj łagodnie w prawo na Cool highway",
"ru": "Плавно поверните направо на Cool highway",
"sv": "Fortsätt med lätt högersväng in på Cool highway",
"vi": "Nghiêng về bên phải vào Cool highway",
"zh-Hans": "继续向右,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_straight.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "straight"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "Geradeaus weiterfahren auf Cool highway",
"en": "Continue onto Cool highway",
"es": "Continua en Cool highway",
"fr": "Continuer tout droit sur Cool highway",
"id": "Terus ke Cool highway",
"nl": "Ga rechtdoor naar Cool highway",
"pl": "Kontynuuj na Cool highway",
"ru": "Продолжите движение по Cool highway",
"sv": "Fortsätt in på Cool highway",
"vi": "Chạy tiếp trên Cool highway",
"zh-Hans": "继续直行,上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_no_number_uturn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "uturn"
},
"name": "Cool highway",
"ref": "Ref no number"
},
"instructions": {
"de": "180°-Wendung auf Cool highway",
"en": "Make a U-turn onto Cool highway",
"es": "Haz un cambio de sentido en Cool highway",
"fr": "Faire demi-tour sur Cool highway",
"id": "Putar balik ke arah Cool highway",
"nl": "Keer om naar Cool highway",
"pl": "Zawróć na Cool highway",
"ru": "Развернитесь на Cool highway",
"sv": "Gör en U-sväng in på Cool highway",
"vi": "Quẹo ngược lại Cool highway",
"zh-Hans": "调头上Cool highway"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_number_left.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "left"
},
"name": "Cool highway",
"ref": "Ref1;Ref2"
},
"instructions": {
"de": "Links weiterfahren auf Ref1",
"en": "Continue left onto Ref1",
"es": "Continua izquierda en Ref1",
"fr": "Continuer à gauche sur Ref1",
"id": "Terus kiri ke Ref1",
"nl": "Ga links naar Ref1",
"pl": "Kontynuuj lewo na Ref1",
"ru": "Двигайтесь налево по Ref1",
"sv": "Fortsätt vänster in på Ref1",
"vi": "Chạy tiếp bên trái trên Ref1",
"zh-Hans": "继续向左,上Ref1"
},
"options": {
"classes": [
"motorway"
]
}
}
28 changes: 28 additions & 0 deletions test/fixtures/v5/other/motorway_ref_has_number_right.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"step": {
"maneuver": {
"type": "continue",
"modifier": "right"
},
"name": "Cool highway",
"ref": "Ref1;Ref2"
},
"instructions": {
"de": "Rechts weiterfahren auf Ref1",
"en": "Continue right onto Ref1",
"es": "Continua derecha en Ref1",
"fr": "Continuer à droite sur Ref1",
"id": "Terus kanan ke Ref1",
"nl": "Ga rechts naar Ref1",
"pl": "Kontynuuj prawo na Ref1",
"ru": "Двигайтесь направо по Ref1",
"sv": "Fortsätt höger in på Ref1",
"vi": "Chạy tiếp bên phải trên Ref1",
"zh-Hans": "继续向右,上Ref1"
},
"options": {
"classes": [
"motorway"
]
}
}
Loading