{"id":13598611,"url":"https://github.com/extensionsapp/translatte","last_synced_at":"2025-04-10T01:09:26.663Z","repository":{"id":57379181,"uuid":"150146208","full_name":"extensionsapp/translatte","owner":"extensionsapp","description":"A free and unlimited translate for NodeJS.","archived":false,"fork":false,"pushed_at":"2021-06-20T21:57:58.000Z","size":622,"stargazers_count":98,"open_issues_count":6,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T01:09:20.529Z","etag":null,"topics":["api","free","google","language","proxy","translate","translator","translatte"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/translatte","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/extensionsapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-24T18:04:21.000Z","updated_at":"2024-10-16T13:13:13.000Z","dependencies_parsed_at":"2022-09-02T20:41:19.534Z","dependency_job_id":null,"html_url":"https://github.com/extensionsapp/translatte","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extensionsapp%2Ftranslatte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extensionsapp%2Ftranslatte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extensionsapp%2Ftranslatte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extensionsapp%2Ftranslatte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extensionsapp","download_url":"https://codeload.github.com/extensionsapp/translatte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137886,"owners_count":21053775,"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","free","google","language","proxy","translate","translator","translatte"],"created_at":"2024-08-01T17:00:54.259Z","updated_at":"2025-04-10T01:09:26.639Z","avatar_url":"https://github.com/extensionsapp.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# A free and unlimited translate for NodeJS.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/extensionsapp/translatte/master/translatte_md.png\" alt=\"TRANSLATTE, npm package translate for NodeJS\" title=\"TRANSLATTE, npm package translate for NodeJS\"\u003e\u003c/p\u003e\n\n### Installation\n```\nnpm i translatte\n```\n\n### Usage\n\nTranslate string to German:\n\n```javascript\nconst translatte = require('translatte');\n\ntranslatte('Do you speak Russian?', {to: 'de'}).then(res =\u003e {\n    console.log(res.text);\n}).catch(err =\u003e {\n    console.error(err);\n});\n// Ihr sprecht auf Russisch?\n```\n\nTranslate string to English using proxy:\n\n```javascript\nconst translatte = require('translatte');\n\ntranslatte('Вы говорите по-русски?', {\n    from: 'ru',\n    to: 'en',\n    agents: [\n        'Mozilla/5.0 (Windows NT 10.0; ...',\n        'Mozilla/4.0 (Windows NT 10.0; ...',\n        'Mozilla/5.0 (Windows NT 10.0; ...'\n    ],\n    proxies: [\n        'LOGIN:PASSWORD@192.0.2.100:12345',\n        'LOGIN:PASSWORD@192.0.2.200:54321'\n    ]\n}).then(res =\u003e {\n    console.log(res);\n}).catch(err =\u003e {\n    console.error(err);\n});\n// { text: 'Do you speak Russian?', \n//   from: { \n//     language: { \n//       didYouMean: false, \n//       iso: 'ru' \n//     }, \n//     text: { \n//       autoCorrected: false, \n//       value: '', \n//       didYouMean: false \n//     } \n//   },\n//   raw: '' }\n```\n\n## API\n\n### translatte(text, options)\n\n#### text\n\nType: `string`\n\nThe text to be translated.\n\n#### options\n\nType: `object`\n\n##### from\n\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/extensionsapp/translatte/blob/master/languages.js).\n\n##### to\n\nType: `string` Default: `en`\n\nThe language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/extensionsapp/translatte/blob/master/languages.js).\n\n##### raw\n\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##### agents\n\nType: `array` Default: `[]`\n\nAn `array` of strings specifying the user-agent `['Mozilla/5.0 ...', 'Mozilla/4.0 ...']`. One random result will be selected.\n\n##### proxies\n\nType: `array` Default: `[]`\n\nAn `array` of strings `LOGIN:PASSWORD@IP:PORT` specifying the proxies `['LOGIN:PASSWORD@192.0.2.100:12345', 'LOGIN:PASSWORD@192.0.2.200:54321']`. One random result will be selected.\n\n##### tld\n\nType: `string` Default: `com`\n\nTLD for Google translate host to be used in API calls: `https://translate.google.[tld]`\n\n##### client\n\nType: `string` Default: `t`\n\nQuery parameter client used in API calls. Can be `t|gtx`.\n\n#### priority\n\nType: `array` Default: `['google_free']`\n\nArray of priority services.\n\n#### services\n\nType: `object` Default: `{\"google_free\": true}`\n\nObjects in order of priority, if one of the services does not perform the translation, it proceeds to the next.\n\n**Supported services:**\n- `{\"google_free\": true}`\n  - \u003ca href=\"https://translate.google.com/\" target=\"_blank\"\u003eGoogle Translate\u003c/a\u003e, this service works by default. It is completely free and has no limits.\n- `{\"google_v3\": {\"project-id\": \"XXX\", \"token\": \"YYY\"}}`\n  - \u003ca href=\"https://cloud.google.com/translate/docs/quickstart-client-libraries-v3\" target=\"_blank\"\u003eGoogle Cloud\u003c/a\u003e, requires registration and credit card details. 500,000 characters per month are issued free of charge, then $20 for every million characters.\n- `{\"microsoft_v3\": {\"key\": \"XXX\", \"location\": \"global\"}}`\n  - \u003ca href=\"https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator-text-api/\" target=\"_blank\"\u003eMicrosoft Azure\u003c/a\u003e, requires registration and credit card details. Free of charge 2,000,000 characters per month, then $10 for every million characters.\n- `{\"yandex_v1\": {\"key\": \"XXX\"}}`\n  - \u003ca href=\"https://translate.yandex.ru/developers/keys\" target=\"_blank\"\u003eYandex Translate\u003c/a\u003e, requires registration. Free of charge 10,000,000 characters per month.\n- `{\"yandex_v2\": {\"key\": \"XXX\"}}`\n  - \u003ca href=\"https://cloud.yandex.ru/docs/translate/\" target=\"_blank\"\u003eYandex Cloud\u003c/a\u003e, requires registration and credit card details. $15 for every million characters.\n\n### Returns an `object`:\n\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/extensionsapp/translatte/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- `proxy` *(string)* – The proxy that were used in the request.\n- `agent` *(string)* – The agent that were used in the request.\n- `service` *(object)* – The service that were used in the request.\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 =\u003e {\n    console.log(res.from.text.value);\n    //=\u003e I [speak] Dutch\n}).catch(err =\u003e {\n    console.error(err);\n});\n```\nOtherwise, it will be an empty `string` (`''`).\n\n### Errors an `object`:\n\nErrors in the name of each `services`.\n\n```json\n{\n  \"google_free\": \"Could not get token from google\",\n  \"google_v3\": \"Response code 403 (Forbidden)\",\n  \"microsoft_v3\": \"Response code 403 (Forbidden)\",\n  \"yandex_v1\": \"Response code 403 (Forbidden)\",\n  \"yandex_v2\": \"Response code 403 (Forbidden)\"\n}\n```\n\nIf the proxy server `LOGIN:PASSWORD@192.0.2.100:12345` is inactive.\n\n```json\n{\n  \"google_free\": \"LOGIN:PASSWORD@192.0.2.100:12345\"\n}\n```\n\nIf the error is not related to `services`.\n\n```json\n{\n  \"message\": \"The language «foo» is not supported\"\n}\n```\n\n**2020 ExtensionsApp**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextensionsapp%2Ftranslatte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextensionsapp%2Ftranslatte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextensionsapp%2Ftranslatte/lists"}