{"id":13606302,"url":"https://github.com/iamtraction/google-translate","last_synced_at":"2025-05-15T17:07:12.671Z","repository":{"id":54476321,"uuid":"121091725","full_name":"iamtraction/google-translate","owner":"iamtraction","description":"🈯 A Node.JS library to consume Google Translate API for free.","archived":false,"fork":false,"pushed_at":"2024-05-15T07:51:47.000Z","size":89,"stargazers_count":555,"open_issues_count":10,"forks_count":77,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-09T04:41:25.617Z","etag":null,"topics":["api","google","google-translate","google-translate-api","hacktoberfest","javascript","js","node","nodejs","translate","translate-api"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@iamtraction/google-translate","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamtraction.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"publiccode":null,"codemeta":null},"funding":{"github":"iamtraction","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"custom":"https://paypal.me/snkrsnkampa"}},"created_at":"2018-02-11T06:12:44.000Z","updated_at":"2025-04-28T03:29:23.000Z","dependencies_parsed_at":"2024-06-18T12:40:35.655Z","dependency_job_id":"1d1c3206-b35a-4f0e-a653-876b0aa5f2ad","html_url":"https://github.com/iamtraction/google-translate","commit_stats":{"total_commits":69,"total_committers":9,"mean_commits":7.666666666666667,"dds":0.6231884057971014,"last_synced_commit":"3b0bbd13d105786cf28deac945f36b0cf7dd1369"},"previous_names":["k3rn31p4nic/google-translate-api"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamtraction%2Fgoogle-translate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamtraction%2Fgoogle-translate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamtraction%2Fgoogle-translate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamtraction%2Fgoogle-translate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamtraction","download_url":"https://codeload.github.com/iamtraction/google-translate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384987,"owners_count":22062422,"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":["api","google","google-translate","google-translate-api","hacktoberfest","javascript","js","node","nodejs","translate","translate-api"],"created_at":"2024-08-01T19:01:07.926Z","updated_at":"2025-05-15T17:07:07.645Z","avatar_url":"https://github.com/iamtraction.png","language":"JavaScript","funding_links":["https://github.com/sponsors/iamtraction","https://paypal.me/snkrsnkampa"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Google Translate API\nA [Node.JS](https://nodejs.org) library to consume Google Translate for free.\n\n[![GitHub release](https://img.shields.io/github/release/iamtraction/google-translate.svg?style=flat)](https://github.com/iamtraction/google-translate/releases)\n[![Dependencies](https://david-dm.org/iamtraction/google-translate.svg)](https://david-dm.org/iamtraction/google-translate)\n[![Known Vulnerabilities](https://snyk.io/test/github/iamtraction/google-translate/badge.svg?targetFile=package.json)](https://snyk.io/test/github/iamtraction/google-translate?targetFile=package.json)\n[![license](https://img.shields.io/github/license/iamtraction/google-translate.svg)](LICENSE)\n\n### Feature Highlights\n* Automatically detect source language\n* Automatic spelling corrections\n* Automatic language correction\n* Fast and reliable\n\n## Table of Contents\n* [Installation](#installation)\n* [Usage](#usage)\n* [Examples](#examples)\n* [Credits, etc](#extras)\n\n## Installation\n```bash\n# Stable version, from npm repository\nnpm install --save @iamtraction/google-translate\n\n# Latest version, from GitHub repository\nnpm install --save iamtraction/google-translate\n```\n\n## Usage\n```js\n// If you've installed from npm, do:\nconst translate = require('@iamtraction/google-translate');\n\n// If you've installed from GitHub, do:\nconst translate = require('google-translate');\n```\n\n#### Method: `translate(text, options)`\n```js\ntranslate(text, options).then(console.log).catch(console.error);\n```\n| Parameter | Type | Optional | Default | Description |\n|-|-|-|-|-|\n| `text` | `String` | No | - | The text you want to translate. |\n| `options` | `Object` | - | - | The options for translating. |\n| `options.from` | `String` | Yes | `'auto'` | The language name/ISO 639-1 code to translate from. If none is given, it will auto detect the source language. |\n| `options.to` | `String` | Yes | `'en'` | The language name/ISO 639-1 code to translate to. If none is given, it will translate to English. |\n| `options.raw` | `Boolean` | Yes | `false` | If `true`, it will return the raw output that was received from Google Translate. |\n\n#### Returns: `Promise\u003cObject\u003e`\n**Response Object:**\n\n| Key | Type | Description |\n|-|-|-|\n| `text` | `String` | The translated text. |\n| `from` | `Object` | - |\n| `from.language` | `Object` | - |\n| `from.language.didYouMean` | `Boolean` | Whether or not the API suggest a correction in the source language. |\n| `from.language.iso` | `String` | The ISO 639-1 code of the language that the API has recognized in the text. |\n| `from.text` | `Object` | - |\n| `from.text.autoCorrected` | `Boolean` | Whether or not the API has auto corrected the original text. |\n| `from.text.value` | `String` | The auto corrected text or the text with suggested corrections. Only returned if `from.text.autoCorrected` or `from.text.didYouMean` is `true`. |\n| `from.text.didYouMean` | `Boolean` | Wherether or not the API has suggested corrections to the text |\n| `raw` | `String` | The raw response from Google Translate servers. Only returned if `options.raw` is `true` in the request options. |\n\n\n## Examples\n#### From automatic language detection to English:\n```js\ntranslate('Tu es incroyable!', { to: 'en' }).then(res =\u003e {\n  console.log(res.text); // OUTPUT: You are amazing!\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n#### From English to French, with a typo:\n```js\ntranslate('Thank you', { from: 'en', to: 'fr' }).then(res =\u003e {\n  console.log(res.text); // OUTPUT: Je vous remercie\n  console.log(res.from.autoCorrected); // OUTPUT: true\n  console.log(res.from.text.value); // OUTPUT: [Thank] you\n  console.log(res.from.text.didYouMean); // OUTPUT: false\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n#### Sometimes Google Translate won't auto correct:\n```js\ntranslate('Thank you', { from: 'en', to: 'fr' }).then(res =\u003e {\n  console.log(res.text); // OUTPUT: ''\n  console.log(res.from.autoCorrected); // OUTPUT: false\n  console.log(res.from.text.value); // OUTPUT: [Thank] you\n  console.log(res.from.text.didYouMean); // OUTPUT: true\n}).catch(err =\u003e {\n  console.error(err);\n});\n```\n\n## Extras\nIf you liked this project, please give it a ⭐ in [**GitHub**](https://github.com/iamtraction/google-translate).\n\n\u003e Credits to [matheuss](https://github.com/matheuss) for writing the original version of this library. I rewrote this, with improvements and without using many external libraries, as his library was not actively developed and had vulnerabilities.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamtraction%2Fgoogle-translate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamtraction%2Fgoogle-translate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamtraction%2Fgoogle-translate/lists"}