Skip to content
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

Update dependencies, translations; add Catalan #312

Merged
merged 26 commits into from
Mar 3, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es2017": true
},
"extends": "eslint:recommended",
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.11.1
16.20.2
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. For change

## master

- This package now requires Node 16 and above. [#312](https://github.com/Project-OSRM/osrm-text-instructions/pull/312)
- Added a Catalan localization. [#312](https://github.com/Project-OSRM/osrm-text-instructions/pull/312)
- Updated translations in Brazilian Portuguese, Danish, Esperanto, French, Hungarian, Japanese, Polish, Russian, Simplified Chinese, Swedish, Ukrainian, and Yoruba. [#312](https://github.com/Project-OSRM/osrm-text-instructions/pull/312)

## 0.14.0 2019-12-04

- Update Japanese localization, add named intersections. [#290](https://github.com/Project-OSRM/osrm-text-instructions/pull/290)
Expand Down
43 changes: 22 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ module.exports = function(version) {
if (instructions[language][version].modes[mode]) {
instructionObject = instructions[language][version].modes[mode];
} else {
// omit side from off ramp if same as driving_side
// note: side will be undefined if the input is from OSRM <5.14
// but the condition should still evaluate properly regardless
// omit side from off ramp if same as driving_side
// note: side will be undefined if the input is from OSRM <5.14
// but the condition should still evaluate properly regardless
var omitSide = type === 'off ramp' && modifier.indexOf(side) >= 0;
if (instructions[language][version][type][modifier] && !omitSide) {
instructionObject = instructions[language][version][type][modifier];
Expand Down Expand Up @@ -271,29 +271,30 @@ module.exports = function(version) {
// Keep this function context to use in inline function below (no arrow functions in ES4)
var that = this;
var startedWithToken = false;
var output = instruction.replace(/\{(\w+)(?::(\w+))?\}/g, function(token, tag, grammar, offset) {
var value = tokens[tag];
var output = instruction
.replace(/\{(\w+)(?::(\w+))?\}/g, function(token, tag, grammar, offset) {
var value = tokens[tag];

// Return unknown token unchanged
if (typeof value === 'undefined') {
return token;
}
// Return unknown token unchanged
if (typeof value === 'undefined') {
return token;
}

value = that.grammarize(language, value, grammar);
value = that.grammarize(language, value, grammar);

// If this token appears at the beginning of the instruction, capitalize it.
if (offset === 0 && instructions[language].meta.capitalizeFirstLetter) {
startedWithToken = true;
value = that.capitalizeFirstLetter(language, value);
}
// If this token appears at the beginning of the instruction, capitalize it.
if (offset === 0 && instructions[language].meta.capitalizeFirstLetter) {
startedWithToken = true;
value = that.capitalizeFirstLetter(language, value);
}

if (options && options.formatToken) {
value = options.formatToken(tag, value);
}
if (options && options.formatToken) {
value = options.formatToken(tag, value);
}

return value;
})
.replace(/ {2}/g, ' '); // remove excess spaces
return value;
})
.replace(/ {2}/g, ' '); // remove excess spaces

if (!startedWithToken && instructions[language].meta.capitalizeFirstLetter) {
return this.capitalizeFirstLetter(language, output);
Expand Down
2 changes: 2 additions & 0 deletions languages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Load all language files explicitly to allow integration
// with bundling tools like webpack and browserify
var instructionsAr = require('./languages/translations/ar.json');
var instructionsCa = require('./languages/translations/ca.json');
var instructionsDa = require('./languages/translations/da.json');
var instructionsDe = require('./languages/translations/de.json');
var instructionsEn = require('./languages/translations/en.json');
Expand Down Expand Up @@ -58,6 +59,7 @@ var abbreviationsVi = require('./languages/abbreviations/vi.json');
// Create a list of supported codes
var instructions = {
'ar': instructionsAr,
'ca': instructionsCa,
'da': instructionsDa,
'de': instructionsDe,
'en': instructionsEn,
Expand Down
Loading