{"id":13701298,"url":"https://github.com/Project-OSRM/osrm-text-instructions","last_synced_at":"2025-05-04T21:30:43.218Z","repository":{"id":48037453,"uuid":"67210187","full_name":"Project-OSRM/osrm-text-instructions","owner":"Project-OSRM","description":"Text instructions from OSRM route responses","archived":false,"fork":false,"pushed_at":"2024-03-04T14:28:08.000Z","size":6968,"stargazers_count":91,"open_issues_count":45,"forks_count":64,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-04-21T09:52:37.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Project-OSRM.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-09-02T09:33:26.000Z","updated_at":"2025-04-05T14:20:06.000Z","dependencies_parsed_at":"2024-04-08T04:11:45.897Z","dependency_job_id":null,"html_url":"https://github.com/Project-OSRM/osrm-text-instructions","commit_stats":{"total_commits":479,"total_committers":28,"mean_commits":"17.107142857142858","dds":0.7703549060542798,"last_synced_commit":"6a77ef9be61b6f3b659177b47e407ccb87b63975"},"previous_names":["project-osrm/osrm-text-instructions.js"],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Project-OSRM%2Fosrm-text-instructions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Project-OSRM%2Fosrm-text-instructions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Project-OSRM%2Fosrm-text-instructions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Project-OSRM%2Fosrm-text-instructions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Project-OSRM","download_url":"https://codeload.github.com/Project-OSRM/osrm-text-instructions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252403674,"owners_count":21742408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T20:01:27.336Z","updated_at":"2025-05-04T21:30:41.553Z","avatar_url":"https://github.com/Project-OSRM.png","language":"JavaScript","readme":"[\u003cimg src=\"https://travis-ci.org/Project-OSRM/osrm-text-instructions.svg?branch=master\" align=\"right\" alt=\"Build status\"\u003e](https://travis-ci.org/Project-OSRM/osrm-text-instructions)\n\n# OSRM Text Instructions\n\nOSRM Text Instructions is a Node.js library that transforms route data generated by [OSRM](http://www.project-osrm.org/) into localized turn instructions to be displayed visually or read aloud by a text-to-speech engine. OSRM Text Instructions is the basis of guidance instructions in [osrm-frontend](https://github.com/Project-OSRM/osrm-frontend/), the [Mapbox Directions API](https://www.mapbox.com/api-documentation/#directions), and the [Mapbox Navigation SDK](https://www.mapbox.com/navigation-sdk/).\n\n* **Global**: Text instructions are available in over a dozen languages via [Transifex](https://www.transifex.com/project-osrm/osrm-text-instructions/). [Abbreviations](languages/abbreviations/README.md) and [advanced grammatical transformations](languages/grammar/README.md) are available in some languages.\n* **Customizable**: Flexible options allow you to format and tweak the results to your liking.\n* **Cross-platform**: A data-driven approach facilitates implementations in other programming languages. OSRM Text Instructions is also available [in Swift and Objective-C](https://github.com/Project-OSRM/osrm-text-instructions.swift/) (for iOS, macOS, tvOS, and watchOS) and [in Java](https://github.com/Project-OSRM/osrm-text-instructions.java/) (for Android and Java SE).\n* **Well-tested**: A data-driven test suite ensures compatibility across languages and platforms.\n\n## Usage\n\n[![NPM](https://nodei.co/npm/osrm-text-instructions.png)](https://npmjs.org/package/osrm-text-instructions/)\n\n```js\nvar version = 'v5';\nvar osrmTextInstructions = require('osrm-text-instructions')(version);\n\nresponse.legs.forEach(function(leg) {\n  leg.steps.forEach(function(step) {\n    instruction = osrmTextInstructions.compile('en', step, options)\n  });\n});\n```\n\nIf you are unsure if the user's locale is supported by osrm-text-inustrctions, use [@mapbox/locale-utils](https://github.com/mapbox/locale-utils) for finding the best fitting language.\n\n#### Parameters `require('osrm-text-instructions')(version)`\n\nparameter | required? | values | description\n---|----|----|---\n`version` | required | `v5` | Major OSRM version\n\n#### Parameters `compile(language, step, options)`\n\nparameter | required? | values | description\n---|----|----|---\n`language` | required | `en` `de` `zh-Hans` `fr` `nl` `ru` [and more](https://github.com/Project-OSRM/osrm-text-instructions/tree/master/languages/translations/) | Compiling instructions for the selected language code.\n`step` | required | [OSRM route step object](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep-object) | The RouteStep as it comes out of OSRM\n`options` | optional | Object | See [below](#options)\n\n##### Options\n\nkey | type | description\n----|----|----\n`legCount` | integer | Number of legs in the route\n`legIndex` | integer | Zero-based index of the leg containing the step; together with `legCount`, this option determines which waypoint the user has arrived at\n`formatToken` | function | Function that formats the given token value after grammaticalization and capitalization but before the value is inserted into the instruction string; useful for wrapping tokens in markup\n`waypointName` | string | Optional custom name for the leg's destination, replaces `\"your {nth} destination\"`\n\n`formatToken` takes two parameters:\n\n* `token`: A string that indicates the kind of token, such as `way_name` or `direction`\n* `value`: A grammatical string for this token, capitalized if the token appears at the beginning of the instruction\n\nand returns a string.\n\n## Architecture\n\n* index.js contains the main transformation logic in JavaScript.\n* languages/ contains the localization files, including raw format strings, abbreviation files, and grammar rules.\n* languages.js loads the localizations and contains some localization-related helper functions.\n* test/ contains data-driven integration tests and test fixtures for all supported languages.\n\n## Contributing\n\nWe welcome feedback, code contributions, and translations! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n[![Transifex](https://www.transifex.com/projects/p/osrm-text-instructions/resource/enjson/chart/image_png)](https://www.transifex.com/project-osrm/osrm-text-instructions/)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProject-OSRM%2Fosrm-text-instructions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FProject-OSRM%2Fosrm-text-instructions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProject-OSRM%2Fosrm-text-instructions/lists"}