Skip to content

Commit 491de3c

Browse files
committed
Initial Hungarian grammar rules to insert articles
1 parent 6477b05 commit 491de3c

File tree

523 files changed

+791
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

523 files changed

+791
-686
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. For change
33

44
## master
55

6-
- Added a Hungarian localization. [#274](https://github.com/Project-OSRM/osrm-text-instructions/pull/274)
6+
- Added a Hungarian localization and grammar. [#274](https://github.com/Project-OSRM/osrm-text-instructions/pull/274)
77
- Added an Arabic localization. [#267](https://github.com/Project-OSRM/osrm-text-instructions/pull/267)
88
- Added a Slovenian localization. [#264](https://github.com/Project-OSRM/osrm-text-instructions/pull/264)
99
- Updated French grammar with 'chaussée' status street name. [#268](https://github.com/Project-OSRM/osrm-text-instructions/pull/268)

languages.js

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

3232
// Load all grammar files
3333
var grammarFr = require('./languages/grammar/fr.json');
34+
var grammarHu = require('./languages/grammar/hu.json');
3435
var grammarRu = require('./languages/grammar/ru.json');
3536

3637
// Load all abbreviations files
@@ -86,6 +87,7 @@ var instructions = {
8687
// Create list of supported grammar
8788
var grammars = {
8889
'fr': grammarFr,
90+
'hu': grammarHu,
8991
'ru': grammarRu
9092
};
9193

languages/grammar/hu.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+
"article": [
7+
["^ ", " a "],
8+
9+
["^ a ([AÁÄÅÂEÉËIÍÏOÓŐÖUÚŰÜYŸАЕЁИОУЭЮЯ])", " az $1"],
10+
["^ a ([FLMNRSXЛМНРСФ][ \\-\\d])", " az $1"],
11+
["^ a ([15][ \\-\\.])", " az $1"],
12+
["^ a (5\\d+[ \\-\\.])", " az $1"]
13+
]
14+
}
15+
}

languages/overrides/hu.js

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

languages/translations/hu.json

Lines changed: 168 additions & 168 deletions
Large diffs are not rendered by default.

test/fixtures/v5/arrive/left.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fi": "Olet saapunut määränpäähäsi, joka on vasemmalla puolellasi",
1818
"fr": "Vous êtes arrivé à votre destination, sur la gauche",
1919
"he": "הגעת אל היעד ה שלך משמאלך",
20-
"hu": "Megérkezett a(z) célponthoz, a bal oldalon",
20+
"hu": "Megérkezett a célponthoz, a bal oldalon",
2121
"id": "Anda telah tiba di tujuan ke-, di sebelah kiri",
2222
"it": "Sei arrivato alla tua destinazione, sulla sinistra",
2323
"ko": "좌측에 목적지가 있습니다.",

test/fixtures/v5/arrive/no_modifier.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"fi": "Olet saapunut määränpäähäsi",
1717
"fr": "Vous êtes arrivé à votre destination",
1818
"he": "הגעת אל היעד ה שלך",
19-
"hu": "Megérkezett a(z) célponthoz",
19+
"hu": "Megérkezett a célponthoz",
2020
"id": "Anda telah tiba di tujuan ke-",
2121
"it": "Sei arrivato alla tua destinazione",
2222
"ko": " 목적지에 도착하였습니다.",

test/fixtures/v5/arrive/right.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fi": "Olet saapunut määränpäähäsi, joka on oikealla puolellasi",
1818
"fr": "Vous êtes arrivé à votre destination, sur la droite",
1919
"he": "הגעת אל היעד ה שלך מימינך",
20-
"hu": "Megérkezett a(z) célponthoz, a jobb oldalon",
20+
"hu": "Megérkezett a célponthoz, a jobb oldalon",
2121
"id": "Anda telah tiba di tujuan ke-, di sebelah kanan",
2222
"it": "Sei arrivato alla tua destinazione, sulla destra",
2323
"ko": "우측에 목적지가 있습니다.",

test/fixtures/v5/arrive/sharp_left.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fi": "Olet saapunut määränpäähäsi, joka on vasemmalla puolellasi",
1818
"fr": "Vous êtes arrivé à votre destination, sur la gauche",
1919
"he": "הגעת אל היעד ה שלך משמאלך",
20-
"hu": "Megérkezett a(z) célponthoz, a bal oldalon",
20+
"hu": "Megérkezett a célponthoz, a bal oldalon",
2121
"id": "Anda telah tiba di tujuan ke-, di sebelah kiri",
2222
"it": "Sei arrivato alla tua destinazione, sulla sinistra",
2323
"ko": "좌측에 목적지가 있습니다.",

test/fixtures/v5/arrive/sharp_right.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fi": "Olet saapunut määränpäähäsi, joka on oikealla puolellasi",
1818
"fr": "Vous êtes arrivé à votre destination, sur la droite",
1919
"he": "הגעת אל היעד ה שלך מימינך",
20-
"hu": "Megérkezett a(z) célponthoz, a jobb oldalon",
20+
"hu": "Megérkezett a célponthoz, a jobb oldalon",
2121
"id": "Anda telah tiba di tujuan ke-, di sebelah kanan",
2222
"it": "Sei arrivato alla tua destinazione, sulla destra",
2323
"ko": "우측에 목적지가 있습니다.",

0 commit comments

Comments
 (0)