Translate text using the Cloud Translation API
Stay organized with collections
Save and categorize content based on your preferences.
Makes an HTTP POST request to the Cloud Translation API to translate text from English to Russian.
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# Translate text using the Cloud Translation API\n\nMakes an HTTP POST request to the Cloud Translation API to translate text from English to Russian.\n\nCode sample\n-----------\n\n### YAML\n\n main:\n params: [args]\n steps:\n - new_translation:\n call: http.post\n args:\n url: ${\"https://translation.googleapis.com/v3/projects/\"+sys.get_env(\"GOOGLE_CLOUD_PROJECT_NUMBER\")+\":translateText\"}\n auth:\n type: OAuth2\n body:\n contents: ${args.textToTranslate}\n sourceLanguageCode: \"en-US\"\n targetLanguageCode: \"ru-RU\"\n result: translate_response\n - assign_translation:\n assign:\n - translation_result: ${translate_response.body.translations[0].translatedText}\n - return_result:\n return: ${translation_result}\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]