Skip to content

Commit

Permalink
Merge pull request #221 from Project-OSRM/add-abbreviations
Browse files Browse the repository at this point in the history
Add abbreviations
  • Loading branch information
danpaz authored Feb 23, 2018
2 parents 7dd9e17 + fb67d90 commit 42e39ed
Show file tree
Hide file tree
Showing 15 changed files with 1,156 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ All notable changes to this project will be documented in this file. For change

## master

- Added abbreviations for multiple languages. [#221](https://github.com/Project-OSRM/osrm-text-instructions/pull/221)
- Updated translations in German. [#220](https://github.com/Project-OSRM/osrm-text-instructions/pull/220)

## 0.11.5 2017-02-08
## 0.11.5 2018-02-08

- Added "exit with number" to phrases. [#217](https://github.com/Project-OSRM/osrm-text-instructions/pull/217)

## 0.11.4 2017-01-29
## 0.11.4 2018-01-29

- Added a Hebrew localization. [#210](https://github.com/Project-OSRM/osrm-text-instructions/pull/210)
- Added a Danish localization. [#208](https://github.com/Project-OSRM/osrm-text-instructions/pull/207)
- Extended ordinals support for Russian street names in grammar rules. [#192](https://github.com/Project-OSRM/osrm-text-instructions/pull/192)

## 0.11.3 2017-01-12
## 0.11.3 2018-01-12

- Added a new phrase for a short arrival and short upcoming arrival case. [#207](https://github.com/Project-OSRM/osrm-text-instructions/pull/207)

## 0.11.2 2017-01-10
## 0.11.2 2018-01-10

- Changed the phrases for forks to just say "Keep left onto [wayname]" (unless we have no information, in which case we still say "Keep left at the fork"). [#205](https://github.com/Project-OSRM/osrm-text-instructions/pull/205)
## 0.11.1 2017-01-02

## 0.11.1 2018-01-02

- Changed the phrases for roundabout turns to match turns at standard intersections. [#203](https://github.com/Project-OSRM/osrm-text-instructions/pull/203)

Expand Down
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ OSRM Text Instructions could support [grammatical cases](https://github.com/Proj

Grammatical cases and other translated strings customization after [Transifex](https://www.transifex.com/project-osrm/osrm-text-instructions/) is handled by [override scripts](https://github.com/Project-OSRM/osrm-text-instructions/tree/master/languages/overrides/).

Common abbreviations in multiple languages [are also available](https://github.com/Project-OSRM/osrm-text-instructions/pull/221).

[![NPM](https://nodei.co/npm/osrm-text-instructions.png)](https://npmjs.org/package/osrm-text-instructions/)

### Design goals
Expand Down Expand Up @@ -106,6 +108,8 @@ To add an own translations:
- Generate fixture strings for the tests via `UPDATE=1 npm test` (see changes in `git diff`)
- Make a PR

Abbreviation translations are currently handled outside of Transifex. Please make a PR to add or edit [abbreviations](https://github.com/Project-OSRM/osrm-text-instructions/tree/master/languages/abbreviations/).

#### Release

- Update CHANGELOG.md
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var languages = require('./languages');
var instructions = languages.instructions;
var grammars = languages.grammars;
var abbreviations = languages.abbreviations;

module.exports = function(version) {
Object.keys(instructions).forEach(function(code) {
Expand Down Expand Up @@ -236,6 +237,7 @@ module.exports = function(version) {

return name;
},
abbreviations: abbreviations,
tokenize: function(language, instruction, tokens, options) {
if (!language) throw new Error('No language code provided');
// Keep this function context to use in inline function below (no arrow functions in ES4)
Expand Down
29 changes: 29 additions & 0 deletions languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ var instructionsZhHans = require('./languages/translations/zh-Hans.json');
// Load all grammar files
var grammarRu = require('./languages/grammar/ru.json');

// Load all abbreviations files
var abbreviationsBg = require('./languages/abbreviations/bg.json');
var abbreviationsCa = require('./languages/abbreviations/ca.json');
var abbreviationsDa = require('./languages/abbreviations/da.json');
var abbreviationsEn = require('./languages/abbreviations/en.json');
var abbreviationsEs = require('./languages/abbreviations/es.json');
var abbreviationsFr = require('./languages/abbreviations/fr.json');
var abbreviationsLt = require('./languages/abbreviations/lt.json');
var abbreviationsNl = require('./languages/abbreviations/nl.json');
var abbreviationsRu = require('./languages/abbreviations/ru.json');
var abbreviationsSv = require('./languages/abbreviations/sv.json');
var abbreviationsVi = require('./languages/abbreviations/vi.json');

// Create a list of supported codes
var instructions = {
'da': instructionsDa,
Expand Down Expand Up @@ -53,6 +66,21 @@ var grammars = {
'ru': grammarRu
};

// Create list of supported abbrevations
var abbreviations = {
'bg': abbreviationsBg,
'ca': abbreviationsCa,
'da': abbreviationsDa,
'en': abbreviationsEn,
'es': abbreviationsEs,
'fr': abbreviationsFr,
'lt': abbreviationsLt,
'nl': abbreviationsNl,
'ru': abbreviationsRu,
'sv': abbreviationsSv,
'vi': abbreviationsVi
};

function parseLanguageIntoCodes (language) {
var match = language.match(/(\w\w)(?:-(\w\w\w\w))?(?:-(\w\w))?/i);
var locale = [];
Expand Down Expand Up @@ -84,5 +112,6 @@ module.exports = {
}),
instructions: instructions,
grammars: grammars,
abbreviations: abbreviations,
parseLanguageIntoCodes: parseLanguageIntoCodes
};
68 changes: 68 additions & 0 deletions languages/abbreviations/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"abbreviations": {
"международен": "Межд",
"старши": "Стрш",
"възел": "Въз",
"пазар": "Mkt",
"светисвети": "СвСв",
"сестра": "сес",
"уилям": "Ум",
"апартаменти": "ап",
"езеро": "Ез",
"свети": "Св",
"център": "Ц-р",
"парк": "Пк",
"маршрут": "М-т",
"площад": "Пл",
"национален": "Нац",
"училище": "Уч",
"река": "Рек",
"поток": "П-к",
"район": "Р-н",
"крепост": "К-т",
"паметник": "Пам",
"университет": "Уни",
"Връх": "Вр",
"точка": "Точ",
"планина": "Пл",
"село": "с.",
"височини": "вис",
"младши": "Мл",
"станция": "С-я",
"проход": "Прох",
"баща": "Бщ"
},
"classifications": {
"шофиране": "Шоф",
"плавен": "Пл",
"място": "Мя",
"тераса": "Тер",
"магистрала": "М-ла",
"площад": "Пл",
"пеш": "Пеш",
"залив": "З-в",
"пътека": "П-ка",
"платно": "Пл",
"улица": "Ул",
"алея": "Ал",
"пешеходна": "Пеш",
"точка": "Тч",
"задминаване": "Задм",
"кръгово": "Кр",
"връх": "Вр",
"съд": "Сд",
"булевард": "Бул",
"път": "Път",
"скоростна": "Скор",
"мост": "Мо"
},
"directions": {
"северозапад": "СЗ",
"североизток": "СИ",
"югозапад": "ЮЗ",
"югоизток": "ЮИ",
"север": "С",
"изток": "И",
"юг": "Ю"
}
}
107 changes: 107 additions & 0 deletions languages/abbreviations/ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"abbreviations": {
"comunicacions": "Com.",
"entitat de població": "Nucli",
"disseminat": "Diss.",
"cap de municipi": "Cap",
"indret": "Indr.",
"comarca": "Cca.",
"relleu del litoral": "Lit.",
"municipi": "Mun.",
"xarxa hidrogràfica": "Curs Fluv.",
"equipament": "Equip.",
"orografia": "Orogr.",
"barri": "Barri",
"edificació": "Edif.",
"edificació històrica": "Edif. Hist.",
"entitat descentralitzada": "E.M.D.",
"element hidrogràfic": "Hidr."
},
"classifications": {
"rotonda": "Rot.",
"carrerada": "Ca.",
"jardí": "J.",
"paratge": "Pge.",
"pont": "Pont",
"lloc": "Lloc",
"rambla": "Rbla.",
"cases": "Cses.",
"barranc": "Bnc.",
"plana": "Plana",
"polígon": "Pol.",
"muralla": "Mur.",
"enllaç": "Ellaç",
"antiga carretera": "Actra",
"glorieta": "Glor.",
"autovia": "Autv.",
"prolongació": "Prol.",
"calçada": "Cda.",
"carretera": "Ctra.",
"pujada": "Pda.",
"torrent": "T.",
"disseminat": "Disse",
"barri": "B.",
"cinturó": "Cinto",
"passera": "Psera",
"sender": "Send.",
"carrer": "C.",
"sèquia": "Sèq.",
"blocs": "Bloc",
"rambleta": "Rblt.",
"partida": "Par.",
"costa": "Cos.",
"sector": "Sec.",
"corraló": "Crral",
"urbanització": "Urb.",
"autopista": "Autp.",
"grup": "Gr.",
"platja": "Pja.",
"jardins": "J.",
"complex": "Comp.",
"portals": "Ptals",
"finca": "Fin.",
"travessera": "Trav.",
"plaça": "Pl.",
"travessia": "Trv.",
"polígon industrial": "PI.",
"passatge": "Ptge.",
"apartaments": "Apmt.",
"mirador": "Mira.",
"antic": "Antic",
"accés": "Acc.",
"colònia": "Col.",
"corriol": "Crol.",
"portal": "Ptal.",
"porta": "Pta.",
"port": "Port",
"carreró": "Cró.",
"riera": "Ra.",
"circumval·lació": "Cval.",
"baixada": "Bda.",
"placeta": "Plta.",
"escala": "Esc.",
"gran via": "GV",
"rial": "Rial",
"conjunt": "Conj.",
"avinguda": "Av.",
"esplanada": "Esp.",
"cantonada": "Cant.",
"ronda": "Rda.",
"corredor": "Cdor.",
"drecera": "Drec.",
"passadís": "Pdís.",
"viaducte": "Vdct.",
"passeig": "Pg.",
"veïnat": "Veï."
},
"directions": {
"sudest": "SE",
"sudoest": "SO",
"nordest": "NE",
"nordoest": "NO",
"est": "E",
"nord": "N",
"oest": "O",
"sud": "S"
}
}
38 changes: 38 additions & 0 deletions languages/abbreviations/da.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"abbreviations": {
"skole": "Sk.",
"ved": "v.",
"centrum": "C.",
"sankt": "Skt.",
"vestre": "v.",
"hospital": "Hosp.",
"stræde": "Str.",
"nordre": "Nr.",
"plads": "Pl.",
"universitet": "Uni.",
"vænge": "vg.",
"station": "St."
},
"classifications": {
"avenue": "Ave",
"gammel": "Gl.",
"dronning": "Dronn.",
"sønder": "Sdr.",
"nørre": "Nr.",
"vester": "V.",
"vestre": "V.",
"øster": "Ø.",
"østre": "Ø.",
"boulevard": "Boul."
},
"directions": {
"sydøst": "",
"nordvest": "NV",
"syd": "S",
"nordøst": "",
"sydvest": "SV",
"vest": "V",
"nord": "N",
"øst": "Ø"
}
}
Loading

0 comments on commit 42e39ed

Please sign in to comment.