Skip to main content
Version: 10.3.1

Translation

Example overview

Problem statement

In the modern world, you need to work with a large number of people from different countries, but since you cannot know all the languages, you use online translators for this. Though, translating each phrase separately takes a lot of time, and this small bot will help you save your time.

Existing manual process

Sometimes, you have to translate some phrases from one language to another. For this, copy one phrase, translate it, and save the result. The process is repeated for each phrase separately.

Automation solution

The bot gets a list of English words or phrases from a spreadsheet, translates them into Spanish online in Google Translate, and saves the translated words or phrases back to the spreadsheet. To define the input and output language, set ISO 2 Letter Language Codes as headers in the input file.

Preconditions

Before you start working, ensure all the requirements are met:

  1. Install Work.AI Developer.
  2. Use the Chrome browser.
  3. Download the example.
    • English to Spanish.xlsx: the input file inside the Translation.zip folder, the standard path for the input folder: C:/.

Getting started

To get started, perform the following actions:

  1. Extract the Translation folder.

  2. Transfer the folder contents into your Recorder workspace: C:/Users/name/workfusion-workspace2/rpae_project.

  3. Open the sample in Recorder.

  4. Set default values for the following variables:

    1. file: for example, the path to the XLSX file with a single column for translation: C:/ManualReconciliationInput.
  5. Click Play recording.

note
  • The input file should contain short abbreviations for input and output languages in cells A1 and B1, for example, en, es, de, and so on. For more information, refer to ISO 2 Letter Language Codes.
  • Input phrases should be in the A column, beginning with the second row.

Script groups

On a high level, the script consists of the following actions.

  1. Open the spreadsheet and grab data to be translated and languages to translate.
  2. Open Google Translate and translate the phrases online.
  3. Save the translated phrases back to the spreadsheet.

Let's explore these steps in detail.

Script workflow

In this example, phrases from the XLSX file are translated into Google Translate, and the results are saved in the same file.

note

Input file requirements are as follows:

  • The file should contain short abbreviations for input and output languages in cells A1 and B1, for example, en, es, de, and so on.
  • Input phrases should be in the A column, beginning with the second row.
  1. The Open Spreadsheet action opens the XLSX file in the background to read phrases and gets the languages to translate.

  2. The Get Column action saves the first column from a file into a List variable.

  3. The Get Cell Value action obtains the language in which the first column will be translated. Get the value from the first cell of the B column and store it in the str_translate_to variable.

  4. The Constant Value action gets the value from the first cell in the first column and stores this value in the str_translate_from variable.

  5. The For Each loop performs actions for all values from list_input_phrases, starting with the second element.

  6. The Open Website action opens http://translate.google.com with certain parameters. In the Site URL field, use variables that contain the languages required for translation.

  7. Web Element > Set value sets the current input phrase from the list_input_phrases variable.

  1. Web Element > Get value gets the output phrase and stores it in the translated variable.

  2. The Expression value adds the output variable to the list_output_phrases variable.

  3. The Open Spreadsheet action opens the XLSX file to add translated phrases.

  4. The Set Active Cell action sets the active cell to add translated phrases to the second column of the table.

  5. The For Each loop performs actions for all values from list_output_phrases.

  6. The Set Сell Value action sets the list_output_phrases value in the cell under the active one.