feat(DeepL Node): Add support for longer texts + Credential tests (#3651)

* Updated DeepL to send data with Body instead of QS allowing larger translations

* Updated Credentials and added test
This commit is contained in:
Jonathan Bennetts
2022-07-05 08:02:25 +01:00
committed by GitHub
parent 088daf952e
commit 88d6cfc07b
3 changed files with 33 additions and 14 deletions

View File

@@ -116,18 +116,18 @@ export class DeepL implements INodeType {
if (resource === 'language') {
if (operation === 'translate') {
let body: IDataObject = {};
const text = this.getNodeParameter('text', i) as string;
const translateTo = this.getNodeParameter('translateTo', i) as string;
const qs = { target_lang: translateTo, text } as IDataObject;
body = { target_lang: translateTo, 'text': text } as IDataObject;
if (additionalFields.sourceLang !== undefined) {
qs.source_lang = ['EN-GB', 'EN-US'].includes(additionalFields.sourceLang as string)
body.source_lang = ['EN-GB', 'EN-US'].includes(additionalFields.sourceLang as string)
? 'EN'
: additionalFields.sourceLang;
}
const response = await deepLApiRequest.call(this, 'GET', '/translate', {}, qs);
const response = await deepLApiRequest.call(this, 'GET', '/translate', body);
responseData.push(response.translations[0]);
}
}