Cloud Translation API Connector Overview

The Workflows connector defines the built-in functions that can be used to access other Google Cloud products within a workflow.

This page provides an overview of the individual connector. There is no need to import or load connector libraries in a workflow—connectors work out of the box when used in a call step.

Cloud Translation API

Integrates text translation into your website or application. To learn more, see the Cloud Translation API documentation.

Cloud Translation connector sample

YAML

# This workflow demonstrates how to use the Cloud Translate connector:
# Translate text from English to French
# Create and delete a glossary (see https://cloud.google.com/translate/docs/advanced/glossary)
# Expected output: "SUCCESS"
- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - location_id: "us-central1"
      - glossary_id: "example-glossary-id"
- list_supported_translation:
    call: googleapis.translate.v2.languages.list
    args:
      target: "fr"
- basic_translate:
    call: googleapis.translate.v2.translations.translate
    args:
      q: "hello world"
      target: "fr"
      format: "text"
      source: "en"
- create_glossary:
    call: googleapis.translate.v3.projects.locations.glossaries.create
    args:
      parent: ${"projects/" + project_id + "/locations/" + location_id}
      body:
        name: ${"projects/" + project_id + "/locations/" + location_id + "/glossaries/" + glossary_id}
        inputConfig:
          gcsSource:
            inputUri: "gs://translate-glossary-source/glossary.csv"
        languagePair:
          sourceLanguageCode: "en-US"
          targetLanguageCode: "fr-CA"
- list_glossaries:
    call: googleapis.translate.v3.projects.locations.glossaries.list
    args:
      parent: ${"projects/" + project_id + "/locations/" + location_id}
- delete_glossary:
    call: googleapis.translate.v3.projects.locations.glossaries.delete
    args:
      name: ${"projects/" + project_id + "/locations/" + location_id + "/glossaries/" + glossary_id}
- the_end:
    return: "SUCCESS"

JSON

[
  {
    "init": {
      "assign": [
        {
          "project_id": "${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}"
        },
        {
          "location_id": "us-central1"
        },
        {
          "glossary_id": "example-glossary-id"
        }
      ]
    }
  },
  {
    "list_supported_translation": {
      "call": "googleapis.translate.v2.languages.list",
      "args": {
        "target": "fr"
      }
    }
  },
  {
    "basic_translate": {
      "call": "googleapis.translate.v2.translations.translate",
      "args": {
        "q": "hello world",
        "target": "fr",
        "format": "text",
        "source": "en"
      }
    }
  },
  {
    "create_glossary": {
      "call": "googleapis.translate.v3.projects.locations.glossaries.create",
      "args": {
        "parent": "${\"projects/\" + project_id + \"/locations/\" + location_id}",
        "body": {
          "name": "${\"projects/\" + project_id + \"/locations/\" + location_id + \"/glossaries/\" + glossary_id}",
          "inputConfig": {
            "gcsSource": {
              "inputUri": "gs://translate-glossary-source/glossary.csv"
            }
          },
          "languagePair": {
            "sourceLanguageCode": "en-US",
            "targetLanguageCode": "fr-CA"
          }
        }
      }
    }
  },
  {
    "list_glossaries": {
      "call": "googleapis.translate.v3.projects.locations.glossaries.list",
      "args": {
        "parent": "${\"projects/\" + project_id + \"/locations/\" + location_id}"
      }
    }
  },
  {
    "delete_glossary": {
      "call": "googleapis.translate.v3.projects.locations.glossaries.delete",
      "args": {
        "name": "${\"projects/\" + project_id + \"/locations/\" + location_id + \"/glossaries/\" + glossary_id}"
      }
    }
  },
  {
    "the_end": {
      "return": "SUCCESS"
    }
  }
]

Module: googleapis.translate.v2.detections

Functions
detect Detects the language of text within a request.

Module: googleapis.translate.v2.languages

Functions
list Returns a list of supported languages for translation.

Module: googleapis.translate.v2.translations

Functions
translate Translates input text, returning translated text.

Module: googleapis.translate.v3.projects

Functions
detectLanguage Detects the language of text within a request.
getSupportedLanguages Returns a list of supported languages for translation.
translateText Translates input text and returns translated text.

Module: googleapis.translate.v3.projects.locations

Functions
batchTranslateText Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
detectLanguage Detects the language of text within a request.
get Gets information about a location.
getSupportedLanguages Returns a list of supported languages for translation.
list Lists information about the supported locations for this service.
translateText Translates input text and returns translated text.

Module: googleapis.translate.v3.projects.locations.glossaries

Functions
create Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.
delete Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.
get Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
list Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Module: googleapis.translate.v3.projects.locations.operations

Functions
cancel Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
delete Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.
get Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
list Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. NOTE: the name binding allows API services to override the binding to use different resource name schemes, such as users/*/operations. To override the binding, API services can add a binding such as "/v1/{name=users/*}/operations" to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.
wait Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. If the operation is already done, the latest state is immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout is used. If the server does not support this method, it returns google.rpc.Code.UNIMPLEMENTED. Note that this method is on a best-effort basis. It may return the latest state before the specified timeout (including immediately), meaning even an immediate response is no guarantee that the operation is done.

Module: googleapis.translate.v3beta1.projects

Functions
detectLanguage Detects the language of text within a request.
getSupportedLanguages Returns a list of supported languages for translation.
translateText Translates input text and returns translated text.

Module: googleapis.translate.v3beta1.projects.locations

Functions
batchTranslateDocument Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
batchTranslateText Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
detectLanguage Detects the language of text within a request.
get Gets information about a location.
getSupportedLanguages Returns a list of supported languages for translation.
list Lists information about the supported locations for this service.
translateDocument Translates documents in synchronous mode.
translateText Translates input text and returns translated text.

Module: googleapis.translate.v3beta1.projects.locations.glossaries

Functions
create Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.
delete Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.
get Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
list Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Module: googleapis.translate.v3beta1.projects.locations.operations

Functions
cancel Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.
delete Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.
get Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
list Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. NOTE: the name binding allows API services to override the binding to use different resource name schemes, such as users/*/operations. To override the binding, API services can add a binding such as "/v1/{name=users/*}/operations" to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.
wait Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. If the operation is already done, the latest state is immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout is used. If the server does not support this method, it returns google.rpc.Code.UNIMPLEMENTED. Note that this method is on a best-effort basis. It may return the latest state before the specified timeout (including immediately), meaning even an immediate response is no guarantee that the operation is done.