Connector for Cloud Translation

Workflows connector that defines the built-in function used to access Cloud Translation within a workflow.

Explore further

For detailed documentation that includes this code sample, see the following:

Code 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"

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.