Skip to content

Commit 80df3cc

Browse files
committed
Initial grammar rules to fix straight and u-turn modifiers
1 parent 400ae60 commit 80df3cc

19 files changed

+82
-31
lines changed

languages.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var instructionsYo = require('./languages/translations/yo.json');
3232
var instructionsZhHans = require('./languages/translations/zh-Hans.json');
3333

3434
// Load all grammar files
35+
var grammarDa = require('./languages/grammar/da.json');
3536
var grammarFr = require('./languages/grammar/fr.json');
3637
var grammarHu = require('./languages/grammar/hu.json');
3738
var grammarRu = require('./languages/grammar/ru.json');
@@ -90,6 +91,7 @@ var instructions = {
9091

9192
// Create list of supported grammar
9293
var grammars = {
94+
'da': grammarDa,
9395
'fr': grammarFr,
9496
'hu': grammarHu,
9597
'ru': grammarRu

languages/grammar/da.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"meta": {
3+
"regExpFlags": "gi"
4+
},
5+
"v5": {
6+
"fork": [
7+
["^ (ligeud) ", "Fortsæt $1 "],
8+
["^ ", "Hold "]
9+
],
10+
"turn": [
11+
["^ (U\\-vending) ", "Foretag en $1 "],
12+
["^ ", "Drej "]
13+
]
14+
}
15+
}

languages/overrides/da.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Add grammar option to {way_name} depending on phrase context
2+
3+
var replaces = [
4+
['Hold +\{modifier\}', '{modifier:fork}'], // eslint-disable-line no-useless-escape
5+
['Drej +\{modifier\}', '{modifier:turn}'] // eslint-disable-line no-useless-escape
6+
];
7+
8+
function optionize(phrase) {
9+
var result = phrase;
10+
replaces.forEach(function(pattern) {
11+
var re = new RegExp(pattern[0], 'gi');
12+
result = result.replace(re, pattern[1]);
13+
});
14+
15+
return result;
16+
}
17+
18+
function iterate(values) {
19+
Object.keys(values).forEach(function (key) {
20+
var value = values[key];
21+
if (typeof value === 'string') {
22+
values[key] = optionize(value);
23+
} else if (typeof value === 'object') {
24+
iterate(value);
25+
}
26+
});
27+
}
28+
29+
module.exports = function(content) {
30+
// Iterate all content string values recursively
31+
iterate(content.v5);
32+
33+
return content;
34+
};

languages/translations/da.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@
117117
},
118118
"continue": {
119119
"default": {
120-
"default": "Drej {modifier}",
121-
"name": "Drej {modifier} videre ad {way_name}",
122-
"destination": "Drej {modifier} mod {destination}",
123-
"exit": "Drej {modifier} ad {way_name}"
120+
"default": "{modifier:turn}",
121+
"name": "{modifier:turn} videre ad {way_name}",
122+
"destination": "{modifier:turn} mod {destination}",
123+
"exit": "{modifier:turn} ad {way_name}"
124124
},
125125
"straight": {
126126
"default": "Fortsæt ligeud",
@@ -164,9 +164,9 @@
164164
},
165165
"end of road": {
166166
"default": {
167-
"default": "Drej {modifier}",
168-
"name": "Drej {modifier} ad {way_name}",
169-
"destination": "Drej {modifier} mod {destination}"
167+
"default": "{modifier:turn}",
168+
"name": "{modifier:turn} ad {way_name}",
169+
"destination": "{modifier:turn} mod {destination}"
170170
},
171171
"straight": {
172172
"default": "Fortsæt ligeud",
@@ -181,9 +181,9 @@
181181
},
182182
"fork": {
183183
"default": {
184-
"default": "Hold {modifier} ved udfletningen",
185-
"name": "Hold {modifier} på {way_name}",
186-
"destination": "Hold {modifier} mod {destination}"
184+
"default": "{modifier:fork} ved udfletningen",
185+
"name": "{modifier:fork} på {way_name}",
186+
"destination": "{modifier:fork} mod {destination}"
187187
},
188188
"slight left": {
189189
"default": "Hold til venstre ved udfletningen",
@@ -425,9 +425,9 @@
425425
},
426426
"roundabout turn": {
427427
"default": {
428-
"default": "Drej {modifier}",
429-
"name": "Drej {modifier} ad {way_name}",
430-
"destination": "Drej {modifier} mod {destination}"
428+
"default": "{modifier:turn}",
429+
"name": "{modifier:turn} ad {way_name}",
430+
"destination": "{modifier:turn} mod {destination}"
431431
},
432432
"left": {
433433
"default": "Drej til venstre",
@@ -461,9 +461,9 @@
461461
},
462462
"turn": {
463463
"default": {
464-
"default": "Drej {modifier}",
465-
"name": "Drej {modifier} ad {way_name}",
466-
"destination": "Drej {modifier} mod {destination}"
464+
"default": "{modifier:turn}",
465+
"name": "{modifier:turn} ad {way_name}",
466+
"destination": "{modifier:turn} mod {destination}"
467467
},
468468
"left": {
469469
"default": "Drej til venstre",

test/fixtures/v5/fork/straight_default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"instructions": {
1111
"ar": " توجّه مباشرة",
12-
"da": "Hold ligeud ved udfletningen",
12+
"da": "Fortsæt ligeud ved udfletningen",
1313
"de": "Geradeaus halten an der Gabelung",
1414
"en": "Keep straight at the fork",
1515
"eo": "Daŭru rekten ĉe la vojforko",

test/fixtures/v5/fork/straight_destination.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"instructions": {
1212
"ar": "توجّه نحو مباشرة لمسافة {distance} ",
13-
"da": "Hold ligeud mod Destination 1",
13+
"da": "Fortsæt ligeud mod Destination 1",
1414
"de": "Geradeaus halten an der Gabelung Richtung Destination 1",
1515
"en": "Keep straight towards Destination 1",
1616
"eo": "Pluu rekten direkte al Destination 1",

test/fixtures/v5/fork/straight_exit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"instructions": {
1212
"ar": "الزم مباشرة على Way Name",
13-
"da": "Hold ligeud på Way Name",
13+
"da": "Fortsæt ligeud på Way Name",
1414
"de": "Geradeaus halten an der Gabelung auf Way Name",
1515
"en": "Keep straight onto Way Name",
1616
"eo": "Pluu rekten al Way Name",

test/fixtures/v5/fork/straight_exit_destination.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"instructions": {
1313
"ar": "توجّه نحو مباشرة لمسافة {distance} ",
14-
"da": "Hold ligeud mod Destination 1",
14+
"da": "Fortsæt ligeud mod Destination 1",
1515
"de": "Geradeaus halten an der Gabelung Richtung Destination 1",
1616
"en": "Keep straight towards Destination 1",
1717
"eo": "Pluu rekten direkte al Destination 1",

test/fixtures/v5/fork/straight_name.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"instructions": {
1111
"ar": "الزم مباشرة على Way Name",
12-
"da": "Hold ligeud på Way Name",
12+
"da": "Fortsæt ligeud på Way Name",
1313
"de": "Geradeaus halten an der Gabelung auf Way Name",
1414
"en": "Keep straight onto Way Name",
1515
"eo": "Pluu rekten al Way Name",

test/fixtures/v5/roundabout_turn/uturn_default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"instructions": {
1111
"ar": " اسلك مسار الدخول الى الدوران",
12-
"da": "Drej U-vending",
12+
"da": "Foretag en U-vending",
1313
"de": "180°-Wendung abbiegen",
1414
"en": "Make a U-turn",
1515
"eo": "Veturu turniĝu malantaŭen",

0 commit comments

Comments
 (0)