
DeepL (AI translation) Actor
Pricing
Pay per usage
Go to Store

DeepL (AI translation) Actor
Receive high-quality translations from/to 24 languages using the DeepL API. It uses a proprietary algorithm with convolutional neural networks (CNNs) and translate far better than e.g. Google Translate. Free Tier is available.
0.0 (0)
Pricing
Pay per usage
3
Total users
15
Monthly users
2
Runs succeeded
0%
Last modified
2 years ago
.editorconfig
root = true
[*]indent_style = spaceindent_size = 4charset = utf-8trim_trailing_whitespace = trueinsert_final_newline = trueend_of_line = lf
.eslintrc
{ "extends": "@apify"}
.gitignore
# This file tells Git which files shouldn't be added to source control
.ideanode_modules
Dockerfile
# First, specify the base Docker image. You can read more about# the available images at https://sdk.apify.com/docs/guides/docker-images# You can also use any other image from Docker Hub.FROM apify/actor-node:16
# Second, copy just package.json and package-lock.json since it should be# the only file that affects "npm install" in the next step, to speed up the buildCOPY package*.json ./
# Install NPM packages, skip optional and development dependencies to# keep the image small. Avoid logging too much and print the dependency# tree for debuggingRUN npm --quiet set progress=false \ && npm install --only=prod --no-optional \ && echo "Installed NPM packages:" \ && (npm list --all || true) \ && echo "Node.js version:" \ && node --version \ && echo "NPM version:" \ && npm --version
# Next, copy the remaining files and directories with the source code.# Since we do this after NPM install, quick build will be really fast# for most source file changes.COPY . ./
# Optionally, specify how to launch the source code of your actor.# By default, Apify's base Docker images define the CMD instruction# that runs the Node.js source code using the command specified# in the "scripts.start" section of the package.json file.# In short, the instruction looks something like this:## CMD npm start
INPUT_SCHEMA.json
{ "title": "Input schema for the apify_project actor.", "type": "object", "schemaVersion": 1, "properties": { "auth_key": { "title": "Authentication Key", "type": "string", "description": "Authentication Key for DeepL API. You can find it here https://www.deepl.com/pro-account/summary", "editor": "textfield" }, "text": { "title": "Source text", "type": "string", "description": "Text you want to translate", "editor": "textarea" }, "target_lang": { "title": "Target language", "type": "string", "editor": "select", "description": "The language (and variant) into which the text should be translated", "default": "EN-GB", "enum": ["BG", "CS", "DA", "DE", "EL", "EN-GB", "EN-US", "ES", "ET", "FI", "FR", "HU", "IT", "JA", "LT", "LV", "NL", "PL", "PT-PT", "PT-BR", "RO", "RU", "SK", "SL", "SV", "ZH"], "enumTitles": ["Bulgarian", "Czech", "Danish", "German", "Greek", "English (British)", "English (American)", "Spanish", "Estonian", "Finnish", "French", "Hungarian", "Italian", "Japanese", "Lithuanian", "Latvian", "Dutch", "Polish", "Portuguese (all Portuguese varieties excluding Brazilian Portuguese)", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovak", "Slovenian", "Swedish", "Chinese"] }, "source_lang": { "title": "Source language", "type": "string", "editor": "select", "description": "Language of the text to be translated. Default is automatic detection.", "default": "", "enum": ["", "BG", "CS", "DA", "DE", "EL", "EN", "ES", "ET", "FI", "FR", "HU", "IT", "JA", "LT", "LV", "NL", "PL", "PT", "RO", "RU", "SK", "SL", "SV", "ZH"], "enumTitles": ["Autodetect","Bulgarian", "Czech", "Danish", "German", "Greek", "English", "Spanish", "Estonian", "Finnish", "French", "Hungarian", "Italian", "Japanese", "Lithuanian", "Latvian", "Dutch", "Polish", "Portuguese (all Portuguese varieties mixed)", "Romanian", "Russian", "Slovak", "Slovenian", "Swedish", "Chinese"] }, "split_sentences": { "title": "Split sentences", "type": "string", "description": "Sets whether the translation engine should first split the input into sentences. This is enabled by default.<br />For applications that send one sentence per text parameter, it is advisable to set split_sentences=0, in order to prevent the engine from splitting the sentence unintentionally.", "editor": "select", "default": "1", "enum": ["0", "1", "nonewlines"], "enumTitles": ["0 - no splitting at all, whole input is treated as one sentence","1 - (default) - splits on punctuation and on newlines","nonewlines - splits on punctuation only, ignoring newlines"] }, "preserve_formatting": { "title": "Preserve formatting", "type": "string", "description": "Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects. <br />The formatting aspects affected by this setting include:<br />-Punctuation at the beginning and end of the sentence<br />-Upper/lower case at the beginning of the sentence", "editor": "select", "default": "0", "enum": ["0", "1"], "enumTitles": ["0 (default) - No, do not preserver formatting","1 - Yes, preserve formatting"] }, "formality": { "title": "Formality", "type": "string", "description": "Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages 'DE' (German), 'FR' (French), 'IT' (Italian), 'ES' (Spanish), 'NL' (Dutch), 'PL' (Polish), 'PT-PT', 'PT-BR' (Portuguese) and 'RU' (Russian).", "editor": "select", "default": "default", "enum": ["default", "more", "less"], "enumTitles": ["Default","More","Less"] }, "glossary_id": { "title": "Glossary ID", "type": "string", "description": "Specify the glossary to use for the translation. Important: This requires the source_lang parameter to be set and the language pair of the glossary has to match the language pair of the request.", "editor": "textfield", "nullable": true } }, "required": ["text","auth_key"]}
apify.json
{ "env": { "npm_config_loglevel": "silent" }}
main.js
1// This is the main Node.js source code file of your actor.2
3// Import Apify SDK. For more information, see https://sdk.apify.com/4const Apify = require('apify');5// Import Got, see https://www.npmjs.com/package/got6const got = require('got');7
8Apify.main(async () => {9 // Get input of the actor (here only for demonstration purposes).10 const input = await Apify.getInput();11 console.log('Input:');12 console.dir(input);13 const auth_key = input.auth_key;14 console.log('Glossary ID:');15 console.log(input.glossary_id)16
17
18 /**19 * Actor code20 */21 const {body} = await got.post('https://api-free.deepl.com/v2/translate?auth_key='+auth_key, {22 form: {23 text: input.text,24 source_lang: input.source_lang,25 target_lang: input.target_lang,26 split_sentences: input.split_sentences,27 preserve_formatting: input.preserve_formatting,28 formality: input.formality/*,29 glossary_id: input.glossary_id*/30 },31 responseType: 'json'32 });33
34 await Apify.setValue('OUTPUT', body);35 body.translations[0].source = input.text;36 await Apify.pushData(body.translations[0]);37
38
39
40
41
42});
package.json
{ "name": "project-empty", "version": "0.0.1", "description": "This is a boilerplate of an Apify actor.", "dependencies": { "apify": "^2.0.7", "got": "latest" }, "devDependencies": { "@apify/eslint-config": "^0.1.3", "eslint": "^7.0.0" }, "scripts": { "start": "node main.js", "lint": "./node_modules/.bin/eslint ./src --ext .js,.jsx", "lint:fix": "./node_modules/.bin/eslint ./src --ext .js,.jsx --fix", "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1" }, "author": "It's not you it's me", "license": "ISC"}