Tutorial: Bulk Translation with the DeepL API and Google Sheets

Summarise this article with AI

Translating text in bulk, such as product descriptions for an e-shop, can eat a lot of time, especially when you are working with hundreds or thousands of records or need to keep the HTML formatting of the text intact. Luckily there is a way to automate the process using the DeepL API and Google Apps Script. This article walks you through creating a script that automatically translates text from Czech into Slovak, German and English, and shows how you can add further languages as needed.

What is DeepL?

DeepL is an advanced translation tool built on deep neural networks, which allow it to produce very accurate and natural translations. Unlike traditional translation systems, which often translate word by word, DeepL uses deep learning to understand the context and nuance of the original text, and that leads to smoother, more accurate translations.

The advantages of using DeepL for translation

DeepL is known for its high accuracy and its ability to capture fine nuances in a text. Thanks to advanced deep-learning algorithms the translations are produced accurately and fast. Translations made with DeepL often sound more natural than those from other translation tools, which matters especially for professional and formal documents.

What you will need

  • A Google account
  • Access to Google Sheets
  • An API key from DeepL

Step 1: Getting an API key from DeepL

  1. Visit the DeepL website.
  2. Register or log in to your account. Note that using the API requires a special API account, which is different from an ordinary translation account.
  3. Go to the API section and generate a new API key.
  4. Store the key somewhere safe; you will need it when setting the script up.

Step 2: Preparing Google Sheets

  1. Open Google Sheets and create a new spreadsheet.
  2. Put the texts you want translated into the first column (column A).

Step 3: Installing the script

  1. In Google Sheets click Extensions > Apps Script.
  2. In the script editor delete all the existing code and paste in the following:
  1. Edit the line const authKey = “YOUR-API-KEY”; at the top of the script and paste in the API key you obtained from DeepL.
  2. Save the script and close the script editor.
  3. Reload Google Sheets.

Step 4: Using the script

  1. After you reload Google Sheets, a new DeepL Translate menu appears in the top bar.
  2. Select the range of cells in column A that you want translated.
  3. Click DeepL Translate and then choose the language you want the text translated into:
    • Translate Czech to Slovak translates the text into Slovak and writes the results into column B.
    • Translate Czech to German translates the text into German and writes the results into column C.
    • Translate Czech to English translates the text into English and writes the results into column D.

How to add more languages to the script

If you want to add further languages, here is how to go about it (and if your source texts are not in Czech, simply change the source language code in the script as well):

  1. Open the script editor again.
  2. Add new functions for translating into the additional languages. For example, if you want to add French:
  1. Add this new function to the menu in the onOpen section:
  1. Save the script and close the editor.
  2. Reload Google Sheets; the new Translate Czech to French option should now be available in the menu.

In this way you can add as many languages as DeepL supports and assign each of them its own column in the spreadsheet. The approach lets you translate large amounts of text efficiently, straight inside Google Sheets, which makes your work considerably easier and faster.

Is this article useful to you and are you citing it? Copy the citation