Skip to content

Instantly share code, notes, and snippets.

@ibolee
Forked from enogylop/deepl_for_google_sheets.txt
Created February 22, 2023 04:11
Show Gist options
  • Save ibolee/6f5fe2fd10c922718554b085b44df961 to your computer and use it in GitHub Desktop.
Save ibolee/6f5fe2fd10c922718554b085b44df961 to your computer and use it in GitHub Desktop.
Deepl script for google sheets
function deepl(value1, value2, value3) {
var url = `https://api-free.deepl.com/v2/translate?auth_key=xxxx-xxxx-xxxx-xxxx-xxxx&text=${value1}&target_lang=${value3}&source_lang=${value2}`;
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
var data = JSON.parse(json);
return data.translations && data.translations.length > 0 ? data.translations[0].text : "No value";
// replace auth_key with a "Deepl for developer" API key
// source : this script is a modified version of
// http://5.9.10.113/67485395/google-sheets-custom-function-to-translate-with-deepl-api-not-working-as-expecte
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment