または StartTextTranslationJobAWS SDKで を使用する CLI - AWS SDK コード例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

または StartTextTranslationJobAWS SDKで を使用する CLI

以下のコード例は、StartTextTranslationJob の使用方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

.NET
AWS SDK for .NET
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.Translate; using Amazon.Translate.Model; /// <summary> /// This example shows how to use Amazon Translate to process the files in /// an Amazon Simple Storage Service (Amazon S3) bucket. The translated results /// will also be stored in an Amazon S3 bucket. /// </summary> public class BatchTranslate { public static async Task Main() { var contentType = "text/plain"; // Set this variable to an S3 bucket location with a folder." // Input files must be in a folder and not at the bucket root." var s3InputUri = "s3://DOC-EXAMPLE-BUCKET1/FOLDER/"; var s3OutputUri = "s3://DOC-EXAMPLE-BUCKET2/"; // This role must have permissions to read the source bucket and to read and // write to the destination bucket where the translated text will be stored. var dataAccessRoleArn = "arn:aws:iam::0123456789ab:role/S3TranslateRole"; var client = new AmazonTranslateClient(); var inputConfig = new InputDataConfig { ContentType = contentType, S3Uri = s3InputUri, }; var outputConfig = new OutputDataConfig { S3Uri = s3OutputUri, }; var request = new StartTextTranslationJobRequest { JobName = "ExampleTranslationJob", DataAccessRoleArn = dataAccessRoleArn, InputDataConfig = inputConfig, OutputDataConfig = outputConfig, SourceLanguageCode = "en", TargetLanguageCodes = new List<string> { "fr" }, }; var response = await StartTextTranslationAsync(client, request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"{response.JobId}: {response.JobStatus}"); } } /// <summary> /// Start the Amazon Translate text translation job. /// </summary> /// <param name="client">The initialized AmazonTranslateClient object.</param> /// <param name="request">The request object that includes details such /// as source and destination bucket names and the IAM Role that will /// be used to access the buckets.</param> /// <returns>The StartTextTranslationResponse object that includes the /// details of the request response.</returns> public static async Task<StartTextTranslationJobResponse> StartTextTranslationAsync(AmazonTranslateClient client, StartTextTranslationJobRequest request) { var response = await client.StartTextTranslationJobAsync(request); return response; } }
  • API 詳細については、「 リファレンスStartTextTranslationJob」の「」を参照してください。 AWS SDK for .NET API

SAP ABAP
SDK の SAP ABAP
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

"Starts an asynchronous batch translation job." "Use batch translation jobs to translate large volumes of text across multiple documents at once." DATA lo_inputdataconfig TYPE REF TO /aws1/cl_xl8inputdataconfig. DATA lo_outputdataconfig TYPE REF TO /aws1/cl_xl8outputdataconfig. DATA lt_targetlanguagecodes TYPE /aws1/cl_xl8tgtlanguagecodes00=>tt_targetlanguagecodestrlist. DATA lo_targetlanguagecodes TYPE REF TO /aws1/cl_xl8tgtlanguagecodes00. "Create an ABAP object for the input data config." CREATE OBJECT lo_inputdataconfig EXPORTING iv_s3uri = iv_input_data_s3uri iv_contenttype = iv_input_data_contenttype. "Create an ABAP object for the output data config." CREATE OBJECT lo_outputdataconfig EXPORTING iv_s3uri = iv_output_data_s3uri. "Create an internal table for target languages." CREATE OBJECT lo_targetlanguagecodes EXPORTING iv_value = iv_targetlanguagecode. INSERT lo_targetlanguagecodes INTO TABLE lt_targetlanguagecodes. TRY. oo_result = lo_xl8->starttexttranslationjob( "oo_result is returned for testing purposes." EXPORTING io_inputdataconfig = lo_inputdataconfig io_outputdataconfig = lo_outputdataconfig it_targetlanguagecodes = lt_targetlanguagecodes iv_dataaccessrolearn = iv_dataaccessrolearn iv_jobname = iv_jobname iv_sourcelanguagecode = iv_sourcelanguagecode ). MESSAGE 'Translation job started.' TYPE 'I'. CATCH /aws1/cx_xl8internalserverex . MESSAGE 'An internal server error occurred. Retry your request.' TYPE 'E'. CATCH /aws1/cx_xl8invparamvalueex . MESSAGE 'The value of the parameter is not valid.' TYPE 'E'. CATCH /aws1/cx_xl8invalidrequestex. MESSAGE 'The request that you made is not valid.' TYPE 'E'. CATCH /aws1/cx_xl8resourcenotfoundex . MESSAGE 'The resource you are looking for has not been found.' TYPE 'E'. CATCH /aws1/cx_xl8toomanyrequestsex. MESSAGE 'You have made too many requests within a short period of time.' TYPE 'E'. CATCH /aws1/cx_xl8unsuppedlanguage00 . MESSAGE 'Amazon Translate does not support translation from the language of the source text into the requested target language.' TYPE 'E'. ENDTRY.
  • API 詳細については、StartTextTranslationJob「」のAWS SDKSAPABAPAPI「」を参照してください。