Run a batch translation using the Cloud Translation connector

Runs a batch translation using the Cloud Translation connector.

Explore further

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

Code sample

YAML

  main 
 : 
  
 steps 
 : 
  
 - 
  
 init 
 : 
  
 assign 
 : 
  
 - 
  
 projectId 
 : 
  
 ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} 
  
 - 
  
 location 
 : 
  
 ${sys.get_env("GOOGLE_CLOUD_LOCATION")} 
  
 - 
  
 inputBucketName 
 : 
  
 ${projectId + "-input-files"} 
  
 - 
  
 outputBucketName 
 : 
  
 ${projectId + "-output-files-" + string(int(sys.now()))} 
  
 - 
  
 createOutputBucket 
 : 
  
 call 
 : 
  
 googleapis.storage.v1.buckets.insert 
  
 args 
 : 
  
 project 
 : 
  
 ${projectId} 
  
 body 
 : 
  
 name 
 : 
  
 ${outputBucketName} 
  
 - 
  
 batchTranslateText 
 : 
  
 call 
 : 
  
 googleapis.translate.v3beta1.projects.locations.batchTranslateText 
  
 args 
 : 
  
 parent 
 : 
  
 ${"projects/" + projectId + "/locations/" + location} 
  
 body 
 : 
  
 inputConfigs 
 : 
  
 gcsSource 
 : 
  
 inputUri 
 : 
  
 ${"gs://" + inputBucketName + "/*"} 
  
 outputConfig 
 : 
  
 gcsDestination 
 : 
  
 outputUriPrefix 
 : 
  
 ${"gs://" + outputBucketName + "/"} 
  
 sourceLanguageCode 
 : 
  
 "en" 
  
 targetLanguageCodes 
 : 
  
 [ 
 "es" 
 , 
  
 "fr" 
 ] 
  
 result 
 : 
  
 batchTranslateTextResult 
 

What's next

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

Create a Mobile Website
View Site in Mobile | Classic
Share by: