Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmitrymyadzelets/ya-translate
Node.js module for Yandex Translate's API
https://github.com/dmitrymyadzelets/ya-translate
api node-module promise tranalte yandex
Last synced: about 2 months ago
JSON representation
Node.js module for Yandex Translate's API
- Host: GitHub
- URL: https://github.com/dmitrymyadzelets/ya-translate
- Owner: DmitryMyadzelets
- License: mit
- Created: 2017-11-23T14:11:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-23T15:37:13.000Z (about 7 years ago)
- Last Synced: 2024-08-08T17:43:38.801Z (5 months ago)
- Topics: api, node-module, promise, tranalte, yandex
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ya-translate
Node.js module for [Yandex Translate API's](https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/) [`translate` method](https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/).
```bash
npm install ya-translate --save
```Get [your own API key](https://translate.yandex.com/developers/keys) first.
## How to use
```javascript
const translate = require('ya-translate')(YOUR-API-KEY)// Translates to English by default
translate('Parli italiano?')
.then(console.log)
.catch(console.error)// { code: 200,
// detected: { lang: 'it' },
// lang: 'it-en',
// text: [ 'Do you speak Italian?' ] }// Translates to a language of your choice
// (yes, the translation might be wrong)translate('Parli italiano?', 'de')
.then(console.log)
.catch(console.error)// { code: 200,
// detected: { lang: 'it' },
// lang: 'it-de',
// text: [ 'Sprechen sie deutsch?' ] }// Can use an object as in the Yandex.Translate API
translate({lang: 'ru', text: 'You can pass an object (see the Yandex.Translate docs)'})
// { code: 200,
// lang: 'en-ru',
// text: [ 'Вы можете передать объект (см. Яндекс.Перевод документов)' ] }// Can translate many texts at once
translate(({lang: 'zh-en', text: ['\u5F00\u6E90', '\u8F6F\u4EF6']})
.then(console.log)
.catch(console.error)
// { code: 200, lang: 'zh-en', text: [ 'Open source', 'Software' ] }```
## Thanks
To [nkt](https://github.com/nkt) and his nicely written [`yandex.translate`](https://github.com/nkt/yandex.translate).
## Links
* Your keys: https://translate.yandex.com/developers/keys
* Your statistics: https://translate.yandex.com/developers/stat
* Docs: https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/