{"_id":"@alexdee2007/google-translate-api","_rev":"1-5d249fba50fa039b1c32bf88782120f2","name":"@alexdee2007/google-translate-api","dist-tags":{"latest":"5.0.1"},"versions":{"5.0.1":{"name":"@alexdee2007/google-translate-api","version":"5.0.1","description":"A free and unlimited API for Google Translate","main":"index.js","scripts":{"test":"xo && nyc ava","coverage":"nyc report --reporter=text-lcov | coveralls && nyc report --reporter=text-lcov > coverage.lcov && codecov","release":"npm test && npm version $VER && npm publish","postrelease":"git push --follow-tags --no-verify","release-patch":"VER=patch npm run release","release-minor":"VER=minor npm run release"},"husky":{"hooks":{"pre-commit":"xo","pre-push":"npm test"}},"repository":{"type":"git","url":"git+https://github.com/alexdee2007/google-translate-api.git"},"keywords":["translate","translator","google","translate","api","free","language"],"author":{"name":"Matheus Fernandes","email":"npm@matheus.top","url":"http://matheus.top"},"license":"MIT","bugs":{"url":"https://github.com/alexdee2007/google-translate-api/issues"},"homepage":"https://github.com/alexdee2007/google-translate-api#readme","dependencies":{"configstore":"^5.0.1","got":"^9.6.0"},"devDependencies":{"ava":"^3.13.0","codecov":"^1.0.1","coveralls":"^2.11.11","husky":"^3.0.4","nyc":"^15.1.0","xo":"^0.16.0"},"xo":{"space":4,"parserOptions":{"ecmaScript":7}},"gitHead":"e44ac574a0324cc1ce0d3f1e362093a3c3fcb89b","_id":"@alexdee2007/google-translate-api@5.0.1","_nodeVersion":"12.18.2","_npmVersion":"6.14.5","dist":{"integrity":"sha512-1bVA8niaKvQlucLRvCm3Mmt5L7xDJ2ufa4SCAcyCsVg8PgEirZ+QiXTo6o8wPh76ndIWvositSZFNGFMdTGxOQ==","shasum":"04492f2d6b4822de6e5a8c2c487deeabe6718ac4","tarball":"https://registry.npmjs.org/@alexdee2007/google-translate-api/-/google-translate-api-5.0.1.tgz","fileCount":8,"unpackedSize":23524,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf29oqCRA9TVsSAnZWagAAQOwP/2eSXAiOGml7vleQJE0A\n4E4OKiTLuQbVy9lC+pdYgJybRPcTgTbnVMB4npUfXzwOIlY9C1Eph6R/8G1l\nH38EmJlZWeICuqdRwrGJUOrmjDwPoU4X0BNHz84uQb9Xa8ceFjAc67dhQLkq\nd1DWjR3yN7F6/0OqZnZSqKpmYCSmU5ysK47Qljw7zuuJ/WHS+kPwi2+fVJjZ\n0dlaGBxOxbqkSTXDbJVfwxMrCI1gTPWtKf1kXXYNEFHi+DOj0l4Y7MQAIVzr\nLhljDM9Dp5OE8oGv9/+rNalpgHsRkoL+Qcgo0g93zLrPIvF/d/JRV5TrBjIh\nqp46t7jn9ABgcL6vrbwamib9k6Pa8TjIikAk9xhvOnJ/XrdiDxJmbIvQrPgn\n2sIoJZcEMg37zKMHwS23BWnzOrKE4M9EacxEt507Hb6up18srWNxevibfiTf\nAJNUislHhetA1cd07W5iO8tOYxQTLR5/GthpNa56oGItVahaEcedPBMJj02Q\nr1k3KKdCNi2xwd10cVi/YIsw9a3Ujsh31g0IY5UO8xvHehdkI6p3kKawu0Es\n9C6yhAqZLJ1oEiyAOZVVmTiweKd6ALYSPr86IAqkf0BKkaYb5kX5So5CniNL\n0xjKZnZia151vQzgUXvYLYItPP9PWdNXjN2EclIvmppHLoNVbPD97FQj9lif\nODjQ\r\n=BYDo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICIiZm52WmIqKClNVyWzDEJxig8WnwLChB4Mv88CDrxIAiBKEbQoTltXSERcmzhha0bOj3WxzbZZ/SLhVzdFe3sc0w=="}]},"_npmUser":{"name":"alexdee2007","email":"alexdee2007@bk.ru"},"directories":{},"maintainers":[{"name":"alexdee2007","email":"alexdee2007@bk.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/google-translate-api_5.0.1_1608243754264_0.6158737481327539"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-17T22:22:34.204Z","5.0.1":"2020-12-17T22:22:34.425Z","modified":"2022-04-04T12:39:38.513Z"},"maintainers":[{"name":"alexdee2007","email":"alexdee2007@bk.ru"}],"description":"A free and unlimited API for Google Translate","homepage":"https://github.com/alexdee2007/google-translate-api#readme","keywords":["translate","translator","google","translate","api","free","language"],"repository":{"type":"git","url":"git+https://github.com/alexdee2007/google-translate-api.git"},"author":{"name":"Matheus Fernandes","email":"npm@matheus.top","url":"http://matheus.top"},"bugs":{"url":"https://github.com/alexdee2007/google-translate-api/issues"},"license":"MIT","readme":"# google-translate-api\n[![Build Status](https://travis-ci.org/vitalets/google-translate-api.svg?branch=master)](https://travis-ci.org/vitalets/google-translate-api)\n[![NPM version](https://img.shields.io/npm/v/@vitalets/google-translate-api.svg)](https://www.npmjs.com/package/@vitalets/google-translate-api)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![Coverage Status](https://coveralls.io/repos/github/vitalets/google-translate-api/badge.svg?branch=master)](https://coveralls.io/github/vitalets/google-translate-api?branch=master)\n\nA **free** and **unlimited** API for Google Translate :dollar::no_entry_sign: for Node.js.\n\n## Features \n\n- Auto language detection\n- Spelling correction\n- Language correction \n- Fast and reliable – it uses the same servers that [translate.google.com](https://translate.google.com) uses\n\n## Why this fork?\nThis fork of original [matheuss/google-translate-api](https://github.com/matheuss/google-translate-api) contains several improvements:\n\n- New option `client=\"t|gtx\"`. Setting `client=\"gtx\"` seems to work even with outdated token, see [this discussion](https://github.com/matheuss/google-translate-api/issues/79#issuecomment-425679193) for details\n- Fixed extraction of TKK ceed from current `https://translate.google.com` sources (via [@vitalets/google-translate-token](https://github.com/vitalets/google-translate-token))\n- Removed unsecure `unsafe-eval` dependency (See [#2](https://github.com/vitalets/google-translate-api/pull/2))\n- Added [daily CI tests](https://travis-ci.org/vitalets/google-translate-api/builds) to get notified if Google API changes\n- Added support for custom `tld` (especially to support `translate.google.cn`, see [#7](https://github.com/vitalets/google-translate-api/pull/7))\n- Added support for outputting pronunciation (see [#17](https://github.com/vitalets/google-translate-api/pull/17))\n- Added support for custom [got](https://github.com/sindresorhus/got) options. It allows to use proxy and bypass request limits (see [#25](https://github.com/vitalets/google-translate-api/pull/25))\n- Added support for language extensions from outside of the API (See [#18](https://github.com/vitalets/google-translate-api/pull/18))\n\n## Install \n\n```\nnpm install @vitalets/google-translate-api\n```\n\n## Usage\n\nFrom automatic language detection to English:\n\n```js\nconst translate = require('@vitalets/google-translate-api');\n\ntranslate('Ik spreek Engels', {to: 'en'}).then(res => {\n    console.log(res.text);\n    //=> I speak English\n    console.log(res.from.language.iso);\n    //=> nl\n}).catch(err => {\n    console.error(err);\n});\n```\n\nFrom English to Dutch with a typo:\n\n```js\ntranslate('I spea Dutch!', {from: 'en', to: 'nl'}).then(res => {\n    console.log(res.text);\n    //=> Ik spreek Nederlands!\n    console.log(res.from.text.autoCorrected);\n    //=> true\n    console.log(res.from.text.value);\n    //=> I [speak] Dutch!\n    console.log(res.from.text.didYouMean);\n    //=> false\n}).catch(err => {\n    console.error(err);\n});\n```\n\nSometimes, the API will not use the auto corrected text in the translation:\n\n```js\ntranslate('I spea Dutch!', {from: 'en', to: 'nl'}).then(res => {\n    console.log(res);\n    console.log(res.text);\n    //=> Ik spea Nederlands!\n    console.log(res.from.text.autoCorrected);\n    //=> false\n    console.log(res.from.text.value);\n    //=> I [speak] Dutch!\n    console.log(res.from.text.didYouMean);\n    //=> true\n}).catch(err => {\n    console.error(err);\n});\n```\n\nYou can also add languages in the code and use them in the translation:\n\n``` js\ntranslate = require('google-translate-api');\ntranslate.languages['sr-Latn'] = 'Serbian Latin';\n\ntranslate('translator', {to: 'sr-Latn'}).then(res => ...);\n```\n\n## Proxy\nGoogle Translate has request limits. If too many requests are made, you can either end up with a 429 or a 503 error.\nYou can use **proxy** to bypass them:\n```js\nconst tunnel = require('tunnel');\ntranslate('Ik spreek Engels', {to: 'en'}, {\n    agent: tunnel.httpsOverHttp({\n    proxy: { \n      host: 'whateverhost',\n      proxyAuth: 'user:pass',\n      port: '8080',\n      headers: {\n        'User-Agent': 'Node'\n      }\n    }\n  }\n)}).then(res => {\n    // do something\n}).catch(err => {\n    console.error(err);\n});\n```\n\n## Does it work from web page context?\nNo. `https://translate.google.com` does not provide [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) http headers allowing access from other domains.\n\n## API\n\n### translate(text, [options], [gotOptions])\n\n#### text\n\nType: `string`\n\nThe text to be translated\n\n#### options\n\nType: `object`\n\n##### from\nType: `string` Default: `auto`\n\nThe `text` language. Must be `auto` or one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/vitalets/google-translate-api/blob/master/languages.js)\n\n##### to\nType: `string` Default: `en`\n\nThe language in which the text should be translated. Must be one of the codes/names (case sensitive!) contained in [languages.js](https://github.com/vitalets/google-translate-api/blob/master/languages.js).\n\n##### raw\nType: `boolean` Default: `false`\n\nIf `true`, the returned object will have a `raw` property with the raw response (`string`) from Google Translate.\n\n##### client\nType: `string` Default: `\"t\"`\n\nQuery parameter `client` used in API calls. Can be `t|gtx`.\n\n##### tld\nType: `string` Default: `\"com\"`\n\nTLD for Google translate host to be used in API calls: `https://translate.google.{tld}`.\n\n#### gotOptions\nType: `object`\n\nThe got options: https://github.com/sindresorhus/got#options\n\n### Returns an `object`:\n- `text` *(string)* – The translated text.\n- `from` *(object)*\n  - `language` *(object)*\n    - `didYouMean` *(boolean)* - `true` if the API suggest a correction in the source language\n    - `iso` *(string)* - The [code of the language](https://github.com/vitalets/google-translate-api/blob/master/languages.js) that the API has recognized in the `text`\n  - `text` *(object)*\n    - `autoCorrected` *(boolean)* – `true` if the API has auto corrected the `text`\n    - `value` *(string)* – The auto corrected `text` or the `text` with suggested corrections\n    - `didYouMean` *(boolean)* – `true` if the API has suggested corrections to the `text`\n- `raw` *(string)* - If `options.raw` is true, the raw response from Google Translate servers. Otherwise, `''`.\n\nNote that `res.from.text` will only be returned if `from.text.autoCorrected` or `from.text.didYouMean` equals to `true`. In this case, it will have the corrections delimited with brackets (`[ ]`):\n\n```js\ntranslate('I spea Dutch').then(res => {\n    console.log(res.from.text.value);\n    //=> I [speak] Dutch\n}).catch(err => {\n    console.error(err);\n});\n```\nOtherwise, it will be an empty `string` (`''`).\n\n## Related\n\n- [`vertaler`](https://github.com/matheuss/vertaler) – CLI for this module\n\n## License\n\nMIT © [Matheus Fernandes](http://matheus.top), forked and maintained by [Vitaliy Potapov](https://github.com/vitalets).\n","readmeFilename":"README.md"}