{"id":13426446,"url":"https://github.com/vsetka/deepl-translator","last_synced_at":"2025-03-15T21:31:14.404Z","repository":{"id":41397994,"uuid":"102788013","full_name":"vsetka/deepl-translator","owner":"vsetka","description":"This module provides promised methods for translating text using DeepL Translator (https://www.deepl.com/translator) undocumented API.","archived":true,"fork":false,"pushed_at":"2024-12-09T04:12:54.000Z","size":205,"stargazers_count":233,"open_issues_count":0,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-12T08:43:05.353Z","etag":null,"topics":["deepl","deepl-translator","machine-translation","node","nodejs","promised","translate","translation","translator"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsetka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2017-09-07T21:36:59.000Z","updated_at":"2024-12-09T04:22:05.000Z","dependencies_parsed_at":"2024-12-26T19:03:22.624Z","dependency_job_id":"f54a4f00-d937-4e32-b48d-51427d46b219","html_url":"https://github.com/vsetka/deepl-translator","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.09999999999999998,"last_synced_commit":"f832478e08b00d4cc366b53553350035073f0562"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsetka%2Fdeepl-translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsetka%2Fdeepl-translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsetka%2Fdeepl-translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsetka%2Fdeepl-translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsetka","download_url":"https://codeload.github.com/vsetka/deepl-translator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792360,"owners_count":20348628,"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":["deepl","deepl-translator","machine-translation","node","nodejs","promised","translate","translation","translator"],"created_at":"2024-07-31T00:01:34.716Z","updated_at":"2025-03-15T21:31:14.393Z","avatar_url":"https://github.com/vsetka.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","nodejs"],"sub_categories":[],"readme":"**Repository not maintained**\n\n# deepl-translator\n\n[![Coverage Status](https://coveralls.io/repos/github/vsetka/deepl-translator/badge.svg?branch=master)](https://coveralls.io/github/vsetka/deepl-translator?branch=master)\n[![Build Status](https://travis-ci.org/vsetka/deepl-translator.svg?branch=master)](https://travis-ci.org/vsetka/deepl-translator)\n[![Known Vulnerabilities](https://snyk.io/test/github/vsetka/deepl-translator/badge.svg)](https://snyk.io/test/github/vsetka/deepl-translator)\n[![npm version](https://img.shields.io/npm/v/deepl-translator.svg)](https://www.npmjs.com/package/deepl-translator)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](#badge)\n\nThis unofficial node module provides promised methods for detecting language and translating text using DeepL Translator (https://www.deepl.com/translator) undocumented API.\n\nDeepL has done a great job with their deep learning translation model which outperforms the competition by a wide margin. An excerpt from their page on that topic:\n\n\u003e ## Blind test\n\u003e 100 sentences were translated by DeepL Translator, Google Translate, Microsoft Translator, and Facebook. Professional translators assessed the translations, without knowing which system produced which results. The translators preferred our translations over the competition's by a factor of 3:1. Here are the results of a test run in August 2017:\n\n![Stats](https://raw.githubusercontent.com/vsetka/deepl-translator/c0076cf2b7324c310725ea615bf972a6289ffe83/stats.png)\n\n# Supported languages:\n\n| **Language code**   | **Language**\n|:--------------------|:---------------------------------------------------------------\n| `EN`                | English\n| `DE`                | German\n| `FR`                | French\n| `ES`                | Spanish\n| `IT`                | Italian\n| `NL`                | Dutch\n| `PL`                | Polish\n\n## Install \n\n```\nyarn add deepl-translator\n```\n\nThis package can also be used on the client since it provides an XHR shim for the HTTP request helper implementation. The shim is defined as a mapping in the `browser` property of the `package.json` so it should be picked up automatically by most of the popular bundlers.\n\n## Usage\n\n```javascript\nconst { translate, detectLanguage, wordAlternatives, translateWithAlternatives } = require('deepl-translator');\n\n// Translate text with explicit source and target languages\ntranslate('Die Übersetzungsqualität von deepl ist erstaunlich!', 'EN', 'DE')\n  .then(res =\u003e console.log(`Translation: ${res.translation}`))\n  .catch(console.error);\n\n// Translate short text with this method to get a few translation alternatives\ntranslateWithAlternatives(\n  'Die Übersetzungsqualität von deepl ist erstaunlich!',\n  'EN'\n)\n  .then(res =\u003e\n    console.log(\n      `Translation alternatives: ${res.translationAlternatives.join(', ')}`\n    )\n  )\n  .catch(console.error);\n\n// Leave out the source language or specify 'auto' to autodetect the input\ntranslate('This is a representative chunk of text in english.', 'DE')\n  .then(res =\u003e console.log(`Translation: ${res.translation}`))\n  .catch(console.error);\n\n// Detect the text language without giving back the translation\ndetectLanguage('Deepl también puede detectar un idioma. ¿Qué idioma es este?')\n  .then(res =\u003e console.log(`Detected language: ${res.languageName}`))\n  .catch(console.error);\n\n// Multi-line translations work as well, even with different source languages mixed in\ntranslate(\n  `Das ist der erste Satz... Das der zweite.\n\n  C'est la troisième phrase.\n\n\n  Y ese es el cuarto.\n  I piąta.`,\n  'EN'\n)\n  .then(res =\u003e console.log(`Translation: ${res.translation}, Resolved languages: ${res.resolvedSourceLanguage}`))\n  .catch(console.error);\n\n  // This method allows for tweaking the translation. By providing a beginning, we define a word or a phrase\n  // for which we want alternative translations within the context of a larger body of text (a sentence).\n  // One of the returned alternatives can then be selected and passed into translateWithAlternatives\n  // as an overriding word/phrase for the beginning of the whole translation.\n  {\n    const text = 'Die Übersetzungsqualität von deepl ist erstaunlich!';\n    // Translates to: 'The translation quality of deepl is amazing!'\n    wordAlternatives(text, 'EN', 'DE', 'The translation')\n      .then(res =\u003e {\n        console.log(`3 Alternative beginnings:`);\n        res.alternatives.slice(0, 3).forEach(alt =\u003e console.log(alt));\n        // Choose the third alternetive\n        return res.alternatives[2];\n      })\n      .then(beginning =\u003e {\n        // Request translation with selected alternative beginning\n        return translateWithAlternatives(text, 'EN', 'DE', beginning);\n      })\n      .then(res =\u003e console.log(`Alternative: ${res.translation}`));\n  }\n```\n\n## API\n\n### translate(text, targetLanguage, sourceLanguage) -\u0026gt; `object`\nThis method translates the input text into a specified target language. Source language can be autodetected. Multi-line text translation is possible with\nline breaks preserved.\n\n**text** (`string`) *Input text to be translated*\n\n**targetLanguage** (`string`) *Language code of the language to translate to*\n\n**sourceLanguage** (`string`) *Language code of the input text language. Can be left out or set to `auto` for automatic language detection.*\n\n**Returns**\n```javascript\n{\n  targetLanguage: 'XY', // Language code(s) of the language that was translate to\n  resolvedSourceLanguage: 'YZ', // Language code(s) of the input language (resolved automatically for autodetect)\n  translation: 'Translated text' // Translated text\n}\n```\n\n### translateWithAlternatives(text, targetLanguage, sourceLanguage, beginning) -\u0026gt; `object`\nThis method translates the input text into a specified target language. Source language can be autodetected. Optionally, a sentence beginning override can be given (should be used in conjunction with `wordAlternatives` which gives contextual phrase/word translations).\n\n**text** (`string`) *Input text to be translated*\n\n**targetLanguage** (`string`) *Language code of the language to translate to*\n\n**sourceLanguage** (`string`) *Language code of the input text language. Can be left out or set to `auto` for automatic language detection.*\n\n**beginning** (`string`) *Override of the translation beginning*\n\n**Returns**\n```javascript\n{\n  targetLanguage: 'XY', // Language code of the language that was translate to\n  resolvedSourceLanguage: 'YZ', // Language code of the input language (resolved automatically for autodetect)\n  translation: 'Translated text', // Translated text\n  translationAlternatives: ['First translated alternative', 'Second translated alternative']\n}\n```\n\n### detectLanguage(text) -\u0026gt; `object`\nThis method detects the language of the input text.\n\n**text** (`string`) *Input text to detect the language on*\n\n**Returns**\n```javascript\n{\n  languageCode: 'XY', // Language code of the input text\n  languageName: 'Some language', // Language name (in English) of the input text\n}\n```\n\n### wordAlternatives(text, targetLanguage, sourceLanguage, beginning) -\u0026gt; `object`\nThis method suggests alternative wordings for a subset of the beginning input text. This means we get alternative translations for the given word or a phrase within a context of the larger body of text (the input `text`). Languages cannot be autodetected.\n\n**text** (`string`) *Input text to be translated*\n\n**targetLanguage** (`string`) *Language code of the language to translate to*\n\n**sourceLanguage** (`string`) *Language code of the input text language*\n\n**beginning** (`string`) *Subset of the translation of `text` for which the contextual alternatives will be provided*\n\n**Returns**\n```javascript\n{\n  targetLanguage: 'XY', // Language code of the language that was translate to\n  resolvedSourceLanguage: 'YZ', // Language code of the input language\n  alternatives: ['An alternative', 'Yet another alternative'], // Array of alternative sentence beginnings\n}\n```\n\n## License\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsetka%2Fdeepl-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsetka%2Fdeepl-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsetka%2Fdeepl-translator/lists"}