{ "name": "Google Text Translator", "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 270, 300 ], "parameters": {}, "typeVersion": 1, "id": "google-text-translator-trigger" }, { "id": "google-text-translator-translate", "name": "Translate with Google NMT", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 520, 300 ], "parameters": { "method": "POST", "url": "https://translation.googleapis.com/language/translate/v2", "authentication": "predefinedCredentialType", "nodeCredentialType": "googleTranslateOAuth2Api", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "x-goog-user-project", "value": "YOUR_GOOGLE_CLOUD_PROJECT_ID" } ] }, "sendBody": true, "contentType": "json", "specifyBody": "json", "jsonBody": "{\"q\":\"Hello from n8n!\",\"target\":\"de\"}", "options": { "timeout": 30000, "redirect": { "redirect": { "followRedirects": false } }, "response": { "response": { "responseFormat": "json", "fullResponse": true, "neverError": false } } } } }, { "id": "google-text-translator-check", "name": "Read translated text", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 740, 300 ], "parameters": { "mode": "runOnceForEachItem", "jsCode": "function readTranslation(body) {\n const translations = body && typeof body === 'object' && body.data && body.data.translations;\n if (!Array.isArray(translations) || translations.length !== 1) throw new Error('Google did not return one translation');\n const translation = translations[0];\n if (!translation || typeof translation !== 'object' || Array.isArray(translation) || typeof translation.translatedText !== 'string') {\n throw new Error('Google did not return translated text');\n }\n return translation;\n}\nasync function translateResult({ body }) {\n return { translation: readTranslation(body) };\n}\n\nreturn { json: readTranslation($json.body) };" } } ], "active": false, "settings": { "executionOrder": "v1" }, "connections": { "On clicking 'execute'": { "main": [ [ { "node": "Translate with Google NMT", "type": "main", "index": 0 } ] ] }, "Translate with Google NMT": { "main": [ [ { "node": "Read translated text", "type": "main", "index": 0 } ] ] } }, "pinData": {} }