1
2
3
4const Apify = require('apify');
5
6const got = require('got');
7
8Apify.main(async () => {
9
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
20
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
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});