{"_id":"@asmagin/google-translate-api","_rev":"5-a589b857bb9345cb408881749b9fd20b","time":{"8.0.0":"2021-08-14T01:16:40.192Z","created":"2021-08-18T15:46:46.056Z","8.0.1":"2021-08-18T15:46:46.506Z","modified":"2022-04-04T15:47:47.052Z","8.0.2":"2021-08-18T18:34:10.292Z"},"name":"@asmagin/google-translate-api","dist-tags":{"latest":"8.0.2"},"versions":{"8.0.1":{"name":"@asmagin/google-translate-api","version":"8.0.1","description":"A free and unlimited API for Google Translate (for Browser and Node.js)","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/asmagin/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/asmagin/google-translate-api/issues"},"homepage":"https://github.com/asmagin/google-translate-api#readme","dependencies":{"axios":"^0.21.1"},"devDependencies":{"ava":"^3.15.0","codecov":"^3.8.1","configstore":"^5.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":"ac49249004011a8f7928903e3c10f35b2a7d63c9","_id":"@asmagin/google-translate-api@8.0.1","_nodeVersion":"14.17.5","_npmVersion":"6.14.14","dist":{"integrity":"sha512-g6LeysFvMUJaI6Kmr5xnghGkQh2j56t/9iAUN4F22+ArE6QVmeRtFLn/pyxdOi/RvukDuabdiuc5eA5I75pipg==","shasum":"523d12f167a17777b7528675d217dbd27f730714","tarball":"https://registry.npmjs.org/@asmagin/google-translate-api/-/google-translate-api-8.0.1.tgz","fileCount":9,"unpackedSize":27881,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHStmCRA9TVsSAnZWagAAFv0P/31V3yVxYw65QP2bFsBe\nzhqwkjwgS3jXtJNkFg1AI05g1LJdZr7OpgvPfozm42arPzYhDnp77FzPauxn\nH50mtsNWM40RZFp6HRjFI8r9L9a3jc3xkuuz9q6fHI5dNI24w1/vNHA8LL7Q\nDKBx8u9/1Pgs2gWKa90xy5dczGg1L0S78j5eY6LxbwomWhqrWaVxgIFnfk2n\nnQwNKw9I9YZLhgz+O6BTTvdwhrW9F8Y6GTxJnHiERgRRfotv31n+vvggJmdE\npooH7XcBuzFVqtFG5siOC0wzsXH+aMOrMz9hLtVW9HNF+oL00AKG8Kxpaz6t\nYUSnSMCaptP51SQ0r6GQdxJZQ1S8D78zZWFscgDCs+SC6ffT1HIyCl3iCdb2\ny5U/X1Pse5gFvyGGR8+lTQQDYn4kabwUQ26D7qgNhMOvkE2D6+zsb8IChBdi\nqTsnC90vh4hOvbpPCBCf0gR9hng3WgeBx2iioZK3rxI4KY8wInvgnNggpn6P\noisZ5vkeDA1GScLHS27k+pP2vl1Ln0IceCET+GHD47MNokkI4xhr7H53VLmA\nNp/8DCwGCv8I0ZKWpOlu60Tvg2CRMfuG9ukwPAwLW58dPjA1xwtMy250958Q\nZyhCj7NIZOcK0Kl+cerTUWiEe6IvzDddoZUOpWtRNFn7nz0xPKAbkrt0kBPa\nVWqf\r\n=cL7v\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAxyi5tH2HETuT8+zu0VklXOAnQwyRnJEv4DC6YOsEwsAiEA1QcsDh/0Ah/LKfpl9Q0VfcNB2Zy/LvyQkZUV6uqE8w0="}]},"_npmUser":{"name":"asmagin","email":"me@asmagin.com"},"directories":{},"maintainers":[{"name":"asmagin","email":"me@asmagin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/google-translate-api_8.0.1_1629301606125_0.212658167591653"},"_hasShrinkwrap":false},"8.0.2":{"name":"@asmagin/google-translate-api","version":"8.0.2","description":"A free and unlimited API for Google Translate (for Browser and Node.js)","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/asmagin/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/asmagin/google-translate-api/issues"},"homepage":"https://github.com/asmagin/google-translate-api#readme","dependencies":{"axios":"^0.21.1","querystring":"^0.2.1"},"devDependencies":{"ava":"^3.15.0","codecov":"^3.8.1","configstore":"^5.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":"97326072a79e52765a190f13e741bf8d8d5774a3","_id":"@asmagin/google-translate-api@8.0.2","_nodeVersion":"14.17.5","_npmVersion":"6.14.14","dist":{"integrity":"sha512-eypKn/aB9d8/X6VDNskaRPT3eYsog9i+1tL0O3vIGIxqEhR3S0eF9vsVmBmrTn9tMOb5pbGaY34tjEzdnuGerQ==","shasum":"b42459d0ab32f4ff952f6a70b80e879f76b2cc7b","tarball":"https://registry.npmjs.org/@asmagin/google-translate-api/-/google-translate-api-8.0.2.tgz","fileCount":9,"unpackedSize":28592,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHVKiCRA9TVsSAnZWagAAu5sP/0/BVaH+r0zvZ5+kcmrS\nNWQe2l4vPJpYzPCDnk+/L1bD/+JFDpF1c+4QjJhFeL4k0FapxgQb10HcRZfM\n2Lzp0XLyVEuRT4r70zsoJkvE8Mg9Mzft0lkTnfXrwSP8mqHCFzBK06q9FdX4\nP/VrLOm6Y4cBp8H0FIseLHnLZwf1DOCdn+T97xPpIgQ9wboeRFwrlyPABa4o\nzHvgCqGniejZF9dmNRUGWYHXfLyv+g2hjx34d0IT3+qFiDR2OY3bZuzItChc\nxz5Eyl6BqNoOS8GKsb6XTbCFeX2HVynwesKzUXmwdOAaW+XLXTSDGH43MPVb\n8ec9k5Jl3wojAYgyWUsJh9GKZPUzC4RVDVwHH//g3n5SBHaWismi/6rJfhSi\nrjCum2Ow6zEBjBl1IBvWPCtBBKSwcbAwGlXzKz06rXk46pq5Z4eAIs7s2pXG\nLGnOEbaFgFGsk3NPQgSzouhR1x2VocVCBBCbbEs5QPtTfYZz+XfFNuoRr/lh\n1/Xi74g5ibn1C8I5pDSndw0gj5nb/6EqH6/db5tPE0U6Plg2mMQpaoLMpZ9S\nLN48pAwGean5SQHzFiuVZum6VJhA1v7liNygVtWzsGVFELa/4+CFDUEVis3z\ny1PyGSLGFf7b6A9Vzc+Zb1ZEFiQPbfgVyuF8h6y6IiRC5689EXRfqGYClbLq\nqe1E\r\n=dtdW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFYMReaYIBGRFJAYXdtJSSUNyue2OQp9HmZQdTuHwufXAiB1O3IoQEFAAJeVlmXZ5Yqovaps/9U4VIeePi92PCgAdQ=="}]},"_npmUser":{"name":"asmagin","email":"me@asmagin.com"},"directories":{},"maintainers":[{"name":"asmagin","email":"me@asmagin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/google-translate-api_8.0.2_1629311650173_0.8689348858251671"},"_hasShrinkwrap":false}},"maintainers":[{"name":"asmagin","email":"me@asmagin.com"}],"description":"A free and unlimited API for Google Translate (for Browser and Node.js)","homepage":"https://github.com/asmagin/google-translate-api#readme","keywords":["translate","translator","google","translate","api","free","language"],"repository":{"type":"git","url":"git+https://github.com/asmagin/google-translate-api.git"},"author":{"name":"Matheus Fernandes","email":"npm@matheus.top","url":"http://matheus.top"},"bugs":{"url":"https://github.com/asmagin/google-translate-api/issues"},"license":"MIT","readme":"# google-translate-api\n[![Actions Status](https://github.com/asmagin/google-translate-api/workflows/autotests/badge.svg)](https://github.com/asmagin/google-translate-api/actions)\n[![NPM version](https://img.shields.io/npm/v/@asmagin/google-translate-api.svg)](https://www.npmjs.com/package/@asmagin/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/asmagin/google-translate-api/badge.svg?branch=master)](https://coveralls.io/github/asmagin/google-translate-api?branch=master)\n\nA **free** and **unlimited** API for Google Translate :dollar: :no_entry_sign: for Browser and 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 [vitalets/google-translate-api](https://github.com/matheuss/google-translate-api) contains several improvements:\n\n- Migrated to Axios for a better browser support.\n- Provide support for proxy config to avoid CORS\n\n## Install \n\n```\nnpm install @asmagin/google-translate-api\n```\n\n## Usage\n\nFrom automatic language detection to English:\n\n```js\nconst translate = require('@asmagin/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\n> Please note that maximum text length for single translation call is **5000** characters. \n> In case of longer text you should split it on chunks, see [#20](https://github.com/asmagin/google-translate-api/issues/20).\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/asmagin/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/asmagin/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/asmagin/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## License\n\nMIT © [Matheus Fernandes](http://matheus.top), forked and maintained by [Vitaliy Potapov](https://github.com/vitalets), forked and maintained by [Alex Smagin](https://github.com/asmagin)\n","readmeFilename":"README.md"}