Connecteur pour Cloud Translation

Connecteur de workflows qui définit la fonction intégrée utilisée pour accéder à Cloud Translation dans un workflow.

Pages de documentation incluant cet exemple de code

Pour afficher l'exemple de code utilisé en contexte, consultez la documentation suivante :

Exemple de code

YAML

# This workflow demonstrates how to use the Cloud Translate connector.
# The workflow translates some texts and then creates/deletes a glossary.
# Expected successful output: "SUCCESS"

- init:
    assign:
    - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
    - location_id: "us-central1"
    - glossary_id: "dummy-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: "zh-CN"
- 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"

Étape suivante

Pour rechercher et filtrer des exemples de code pour d'autres produits Google Cloud, consultez l'exemple de navigateur Google Cloud.