{"_id":"@34r7h/google-translate-api","_rev":"1-a9ba95d398df7933ce8cae53a8da1b60","name":"@34r7h/google-translate-api","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@34r7h/google-translate-api","version":"4.0.0","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/34r7h/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/vitalets/google-translate-api/issues"},"homepage":"https://github.com/vitalets/google-translate-api#readme","dependencies":{"configstore":"^5.0.1","got":"^9.6.0"},"devDependencies":{"ava":"^3.15.0","codecov":"^3.8.1","coveralls":"^2.11.11","husky":"^3.0.4","nyc":"^15.1.0","xo":"^0.16.0"},"xo":{"space":4,"parserOptions":{"ecmaScript":7}},"gitHead":"2e8cd6baed2a169a7f3f70bcb20ceaf7a5532fe2","_id":"@34r7h/google-translate-api@4.0.0","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"integrity":"sha512-E9Wby2E2sIPoiVILPLivf4jWh1/cv2p5N9T6nmqj9/m7863q/8aGXBuiDCiq+SPSgy9vaYpmn45oo0fnGrFmsA==","shasum":"e0e42fe66442fa373b7ed35d921d257d309b908a","tarball":"https://registry.npmjs.org/@34r7h/google-translate-api/-/google-translate-api-4.0.0.tgz","fileCount":8,"unpackedSize":23745,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDdcACRA9TVsSAnZWagAAFiYP/Akzaf7gaiJk+Ix3bK4K\nC27dBnfpXbvdb1T3NN4hL2GXdlncZEgQxyXr+fneG/BABh8eYnxCniOjmKKd\nGrHWe9UckTya1yl+66O97Ai0n2zj1p7g28aqlQIOLtyGNmI4epiS9aDNS7jg\nPLCjwuxlGNCezeFMIiV92g6C9gBKklnHZ2BRSwOZhkikHUuUxaKxQ/PyePYs\nRK4Knfx5rQZbzqR/CcNR1RI9blQu4wryvxpCseSzhb2JW+7zEAFWxDfyM9b5\nVsy3UQBIXyoW5+6ZsgS+JAJLJDh7ITOdUi09BPcjl/6Vtm4xZJp429Kk7Vhc\nWPU3KV0NvCPkpsk4exKlKaNx6mKejKNNYuox7vlvLK7w5nm4VOv6UWpNq5ME\n1JI4pl9dlb33p6hgevY0kESROJ9m76fLQMSM06yO5m/6txpubgJzPZo+g0cP\nYmrX5KAlPG5U/xtpIDcGJ5eGnv7+J6HrSYReRYLdtBU4Fo76fetf4c8dGLXL\n4lwq74+F4vnezigvE/qYUddiKBxEXt3X8efYjSGpYe7gPfGSxm5jJ1dmklbk\nzp8WtHCJoDiDGyRzswW19IBIG7FY1tf9oJyrGnaRddk/1zHOfHVF8qkPXMlg\nywfo/T2TfsUW2VH0DoVEYNC22sG+YiwSUDvUjBd4B0KVFKY7HUvAH/nXH1uJ\nmMUZ\r\n=QozT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHqTDu2oWrhQy3T+O4X9FR7KubCVQEcU+A5eOewCUaXMAiEA9UdDdhQTYqB5gxBQrRb0XdAyjg6DAeZE0C+6pflt/hk="}]},"_npmUser":{"name":"34r7h","email":"jus.tice.pla.nt+np.m@gmail.com"},"directories":{},"maintainers":[{"name":"34r7h","email":"jus.tice.pla.nt+np.m@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/google-translate-api_4.0.0_1611519743868_0.37620485118769964"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-24T20:22:23.829Z","4.0.0":"2021-01-24T20:22:23.990Z","modified":"2022-04-04T10:43:36.744Z"},"maintainers":[{"name":"34r7h","email":"jus.tice.pla.nt+np.m@gmail.com"}],"description":"A free and unlimited API for Google Translate","homepage":"https://github.com/vitalets/google-translate-api#readme","keywords":["translate","translator","google","translate","api","free","language"],"repository":{"type":"git","url":"git+https://github.com/34r7h/google-translate-api.git"},"author":{"name":"Matheus Fernandes","email":"npm@matheus.top","url":"http://matheus.top"},"bugs":{"url":"https://github.com/vitalets/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"}