How to translate text using the Google Translate API in ODBC

Introduction

This article will guide you through the process of connecting to the Google Translate API using the ZappySys ODBC JSON Driver. Following the steps outlined, you can retrieve translation data directly into your ODBC-compatible applications, enabling you to handle multilingual content quickly and efficiently. Whether you translate customer feedback, product descriptions, or internal documents, this integration will simplify the task and ensure your data workflows remain seamless and practical.

Prerequisites

Steps

Create/Select a Project in the Google API Console

  1. Navigate to the Google API Console.

  2. Click on the Project Dropdown in the top bar and either select an existing project or create a new one by clicking CREATE PROJECT.

  3. Once the project is set, click ENABLE APIS AND SERVICES.

  4. Enable the Cloud Translation API by searching for it and clicking ENABLE.
    Enable Service

  5. Return to the main screen and click on the OAuth Consent Screen tab. Provide the necessary details and save.

  6. Move to the Credentials tab.

  7. Click CREATE CREDENTIALS in the top bar, and choose API Key. You will receive a new API key, which you should save for later use.

Create a New Driver

  1. Open the ODBC Data Source by typing “ODBC” in the search box and launching the ODBC Data Source.
    Open ODBC Data Source

  2. To gain access for yourself or other users, go to the User DSN or System DSN. Go to the System tab for SQL Server Integration and add a new System DSN. Click the “Add” button.
    ZappySys ODBC Driver - Open UI

  3. From the driver list, select ZappySys JSON Driver.
    Select JSON Driver

Connect with Google Translate API in ODBC JSON Driver

  1. Enter the following URL:
    https://translation.googleapis.com/language/translate/v2

  2. Select the POST method and add the following JSON in the Body to translate English to French:

    {
      "q": "This is an example of a JSON source",
      "source": "en",
      "target": "fr",
      "format": "text"
    }
    

    For more details on each parameter, refer to the Google Translate API documentation:

    • q: The text to be translated.
    • source: The text’s source language is set to one of the language codes listed in Language Support. If not specified, the API will attempt to detect the language automatically.
    • target: The translation’s target language is set to one of the language codes listed in Language Support.
    • format: The format of the source text (e.g., text or HTML).
  3. Set the Body content type to JSON(application/json) and include your API key in the Header:
    Authorization: Bearer YOUR_API_KEY

  4. For the Array Filter, use the following to retrieve the translated text:
    $.data.translations[*].translatedText

  5. Click on Test Connection to validate the connection.

  6. Go to the Preview tab and press Preview Data to check the result. Press OK to save the configuration.

Considerations

Save your API Key to avoid having to retrieve it from your account each time you connect.

Video Tutorial

Conclusion

Following these steps, you can seamlessly connect to the Google Translate API within ODBC JSON Driver using ZappySys tools, ensuring efficient data retrieval and integration. If you encounter any issues or need further assistance, our support team is available via chat on our website.

References