Package com.google.cloud.translate.v3 (2.5.0)

A client to Cloud Translation API

The interfaces provided are listed below, along with usage samples.

TranslationServiceClient

Service Description: Provides natural language translation operations.

Sample for TranslationServiceClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   String targetLanguageCode = "targetLanguageCode-106414698";
   List<String> contents = new ArrayList<>();
   TranslateTextResponse response =
       translationServiceClient.translateText(parent, targetLanguageCode, contents);
 }
 

Classes

BatchDocumentInputConfig

Input configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchDocumentInputConfig

BatchDocumentInputConfig.Builder

Input configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchDocumentInputConfig

BatchDocumentOutputConfig

Output configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchDocumentOutputConfig

BatchDocumentOutputConfig.Builder

Output configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchDocumentOutputConfig

BatchTranslateDocumentMetadata

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentMetadata

BatchTranslateDocumentMetadata.Builder

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentMetadata

BatchTranslateDocumentRequest

The BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentRequest

BatchTranslateDocumentRequest.Builder

The BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentRequest

BatchTranslateDocumentResponse

Stored in the google.longrunning.Operation.response field returned by BatchTranslateDocument if at least one document is translated successfully.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentResponse

BatchTranslateDocumentResponse.Builder

Stored in the google.longrunning.Operation.response field returned by BatchTranslateDocument if at least one document is translated successfully.

Protobuf type google.cloud.translation.v3.BatchTranslateDocumentResponse

BatchTranslateMetadata

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3.BatchTranslateMetadata

BatchTranslateMetadata.Builder

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3.BatchTranslateMetadata

BatchTranslateResponse

Stored in the google.longrunning.Operation.response field returned by BatchTranslateText if at least one sentence is translated successfully.

Protobuf type google.cloud.translation.v3.BatchTranslateResponse

BatchTranslateResponse.Builder

Stored in the google.longrunning.Operation.response field returned by BatchTranslateText if at least one sentence is translated successfully.

Protobuf type google.cloud.translation.v3.BatchTranslateResponse

BatchTranslateTextRequest

The batch translation request.

Protobuf type google.cloud.translation.v3.BatchTranslateTextRequest

BatchTranslateTextRequest.Builder

The batch translation request.

Protobuf type google.cloud.translation.v3.BatchTranslateTextRequest

CreateGlossaryMetadata

Stored in the google.longrunning.Operation.metadata field returned by CreateGlossary.

Protobuf type google.cloud.translation.v3.CreateGlossaryMetadata

CreateGlossaryMetadata.Builder

Stored in the google.longrunning.Operation.metadata field returned by CreateGlossary.

Protobuf type google.cloud.translation.v3.CreateGlossaryMetadata

CreateGlossaryRequest

Request message for CreateGlossary.

Protobuf type google.cloud.translation.v3.CreateGlossaryRequest

CreateGlossaryRequest.Builder

Request message for CreateGlossary.

Protobuf type google.cloud.translation.v3.CreateGlossaryRequest

DeleteGlossaryMetadata

Stored in the google.longrunning.Operation.metadata field returned by DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryMetadata

DeleteGlossaryMetadata.Builder

Stored in the google.longrunning.Operation.metadata field returned by DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryMetadata

DeleteGlossaryRequest

Request message for DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryRequest

DeleteGlossaryRequest.Builder

Request message for DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryRequest

DeleteGlossaryResponse

Stored in the google.longrunning.Operation.response field returned by DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryResponse

DeleteGlossaryResponse.Builder

Stored in the google.longrunning.Operation.response field returned by DeleteGlossary.

Protobuf type google.cloud.translation.v3.DeleteGlossaryResponse

DetectLanguageRequest

The request message for language detection.

Protobuf type google.cloud.translation.v3.DetectLanguageRequest

DetectLanguageRequest.Builder

The request message for language detection.

Protobuf type google.cloud.translation.v3.DetectLanguageRequest

DetectLanguageResponse

The response message for language detection.

Protobuf type google.cloud.translation.v3.DetectLanguageResponse

DetectLanguageResponse.Builder

The response message for language detection.

Protobuf type google.cloud.translation.v3.DetectLanguageResponse

DetectedLanguage

The response message for language detection.

Protobuf type google.cloud.translation.v3.DetectedLanguage

DetectedLanguage.Builder

The response message for language detection.

Protobuf type google.cloud.translation.v3.DetectedLanguage

DocumentInputConfig

A document translation request input config.

Protobuf type google.cloud.translation.v3.DocumentInputConfig

DocumentInputConfig.Builder

A document translation request input config.

Protobuf type google.cloud.translation.v3.DocumentInputConfig

DocumentOutputConfig

A document translation request output config.

Protobuf type google.cloud.translation.v3.DocumentOutputConfig

DocumentOutputConfig.Builder

A document translation request output config.

Protobuf type google.cloud.translation.v3.DocumentOutputConfig

DocumentTranslation

A translated document message.

Protobuf type google.cloud.translation.v3.DocumentTranslation

DocumentTranslation.Builder

A translated document message.

Protobuf type google.cloud.translation.v3.DocumentTranslation

GcsDestination

The Google Cloud Storage location for the output content.

Protobuf type google.cloud.translation.v3.GcsDestination

GcsDestination.Builder

The Google Cloud Storage location for the output content.

Protobuf type google.cloud.translation.v3.GcsDestination

GcsSource

The Google Cloud Storage location for the input content.

Protobuf type google.cloud.translation.v3.GcsSource

GcsSource.Builder

The Google Cloud Storage location for the input content.

Protobuf type google.cloud.translation.v3.GcsSource

GetGlossaryRequest

Request message for GetGlossary.

Protobuf type google.cloud.translation.v3.GetGlossaryRequest

GetGlossaryRequest.Builder

Request message for GetGlossary.

Protobuf type google.cloud.translation.v3.GetGlossaryRequest

GetSupportedLanguagesRequest

The request message for discovering supported languages.

Protobuf type google.cloud.translation.v3.GetSupportedLanguagesRequest

GetSupportedLanguagesRequest.Builder

The request message for discovering supported languages.

Protobuf type google.cloud.translation.v3.GetSupportedLanguagesRequest

Glossary

Represents a glossary built from user provided data.

Protobuf type google.cloud.translation.v3.Glossary

Glossary.Builder

Represents a glossary built from user provided data.

Protobuf type google.cloud.translation.v3.Glossary

Glossary.LanguageCodePair

Used with unidirectional glossaries.

Protobuf type google.cloud.translation.v3.Glossary.LanguageCodePair

Glossary.LanguageCodePair.Builder

Used with unidirectional glossaries.

Protobuf type google.cloud.translation.v3.Glossary.LanguageCodePair

Glossary.LanguageCodesSet

Used with equivalent term set glossaries.

Protobuf type google.cloud.translation.v3.Glossary.LanguageCodesSet

Glossary.LanguageCodesSet.Builder

Used with equivalent term set glossaries.

Protobuf type google.cloud.translation.v3.Glossary.LanguageCodesSet

GlossaryInputConfig

Input configuration for glossaries.

Protobuf type google.cloud.translation.v3.GlossaryInputConfig

GlossaryInputConfig.Builder

Input configuration for glossaries.

Protobuf type google.cloud.translation.v3.GlossaryInputConfig

GlossaryName

GlossaryName.Builder

Builder for projects/{project}/locations/{location}/glossaries/{glossary}.

InputConfig

Input configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3.InputConfig

InputConfig.Builder

Input configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3.InputConfig

ListGlossariesRequest

Request message for ListGlossaries.

Protobuf type google.cloud.translation.v3.ListGlossariesRequest

ListGlossariesRequest.Builder

Request message for ListGlossaries.

Protobuf type google.cloud.translation.v3.ListGlossariesRequest

ListGlossariesResponse

Response message for ListGlossaries.

Protobuf type google.cloud.translation.v3.ListGlossariesResponse

ListGlossariesResponse.Builder

Response message for ListGlossaries.

Protobuf type google.cloud.translation.v3.ListGlossariesResponse

LocationName

LocationName.Builder

Builder for projects/{project}/locations/{location}.

OutputConfig

Output configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3.OutputConfig

OutputConfig.Builder

Output configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3.OutputConfig

SupportedLanguage

A single supported language response corresponds to information related to one supported language.

Protobuf type google.cloud.translation.v3.SupportedLanguage

SupportedLanguage.Builder

A single supported language response corresponds to information related to one supported language.

Protobuf type google.cloud.translation.v3.SupportedLanguage

SupportedLanguages

The response message for discovering supported languages.

Protobuf type google.cloud.translation.v3.SupportedLanguages

SupportedLanguages.Builder

The response message for discovering supported languages.

Protobuf type google.cloud.translation.v3.SupportedLanguages

TranslateDocumentRequest

A document translation request.

Protobuf type google.cloud.translation.v3.TranslateDocumentRequest

TranslateDocumentRequest.Builder

A document translation request.

Protobuf type google.cloud.translation.v3.TranslateDocumentRequest

TranslateDocumentResponse

A translated document response message.

Protobuf type google.cloud.translation.v3.TranslateDocumentResponse

TranslateDocumentResponse.Builder

A translated document response message.

Protobuf type google.cloud.translation.v3.TranslateDocumentResponse

TranslateTextGlossaryConfig

Configures which glossary should be used for a specific target language, and defines options for applying that glossary.

Protobuf type google.cloud.translation.v3.TranslateTextGlossaryConfig

TranslateTextGlossaryConfig.Builder

Configures which glossary should be used for a specific target language, and defines options for applying that glossary.

Protobuf type google.cloud.translation.v3.TranslateTextGlossaryConfig

TranslateTextRequest

The request message for synchronous translation.

Protobuf type google.cloud.translation.v3.TranslateTextRequest

TranslateTextRequest.Builder

The request message for synchronous translation.

Protobuf type google.cloud.translation.v3.TranslateTextRequest

TranslateTextResponse

Protobuf type google.cloud.translation.v3.TranslateTextResponse

TranslateTextResponse.Builder

Protobuf type google.cloud.translation.v3.TranslateTextResponse

Translation

A single translation response.

Protobuf type google.cloud.translation.v3.Translation

Translation.Builder

A single translation response.

Protobuf type google.cloud.translation.v3.Translation

TranslationServiceClient

Service Description: Provides natural language translation operations.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   String targetLanguageCode = "targetLanguageCode-106414698";
   List<String> contents = new ArrayList<>();
   TranslateTextResponse response =
       translationServiceClient.translateText(parent, targetLanguageCode, contents);
 }
 

Note: close() needs to be called on the TranslationServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of TranslationServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TranslationServiceSettings translationServiceSettings =
     TranslationServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 TranslationServiceClient translationServiceClient =
     TranslationServiceClient.create(translationServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TranslationServiceSettings translationServiceSettings =
     TranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 TranslationServiceClient translationServiceClient =
     TranslationServiceClient.create(translationServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TranslationServiceSettings translationServiceSettings =
     TranslationServiceSettings.newBuilder()
         .setTransportChannelProvider(
             TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
         .build();
 TranslationServiceClient translationServiceClient =
     TranslationServiceClient.create(translationServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

TranslationServiceClient.ListGlossariesFixedSizeCollection

TranslationServiceClient.ListGlossariesPage

TranslationServiceClient.ListGlossariesPagedResponse

TranslationServiceGrpc

Provides natural language translation operations.

TranslationServiceGrpc.TranslationServiceBlockingStub

Provides natural language translation operations.

TranslationServiceGrpc.TranslationServiceFutureStub

Provides natural language translation operations.

TranslationServiceGrpc.TranslationServiceImplBase

Provides natural language translation operations.

TranslationServiceGrpc.TranslationServiceStub

Provides natural language translation operations.

TranslationServiceProto

TranslationServiceSettings

Settings class to configure an instance of TranslationServiceClient.

The default instance has everything set to sensible defaults:

  • The default service address (translate.googleapis.com) and default port (443) are used.
  • Credentials are acquired automatically through Application Default Credentials.
  • Retries are configured for idempotent methods but not for non-idempotent methods.

The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.

For example, to set the total timeout of translateText to 30 seconds:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TranslationServiceSettings.Builder translationServiceSettingsBuilder =
     TranslationServiceSettings.newBuilder();
 translationServiceSettingsBuilder
     .translateTextSettings()
     .setRetrySettings(
         translationServiceSettingsBuilder.translateTextSettings().getRetrySettings().toBuilder()
             .setTotalTimeout(Duration.ofSeconds(30))
             .build());
 TranslationServiceSettings translationServiceSettings =
     translationServiceSettingsBuilder.build();
 

TranslationServiceSettings.Builder

Builder for TranslationServiceSettings.

Interfaces

BatchDocumentInputConfigOrBuilder

BatchDocumentOutputConfigOrBuilder

BatchTranslateDocumentMetadataOrBuilder

BatchTranslateDocumentRequestOrBuilder

BatchTranslateDocumentResponseOrBuilder

BatchTranslateMetadataOrBuilder

BatchTranslateResponseOrBuilder

BatchTranslateTextRequestOrBuilder

CreateGlossaryMetadataOrBuilder

CreateGlossaryRequestOrBuilder

DeleteGlossaryMetadataOrBuilder

DeleteGlossaryRequestOrBuilder

DeleteGlossaryResponseOrBuilder

DetectLanguageRequestOrBuilder

DetectLanguageResponseOrBuilder

DetectedLanguageOrBuilder

DocumentInputConfigOrBuilder

DocumentOutputConfigOrBuilder

DocumentTranslationOrBuilder

GcsDestinationOrBuilder

GcsSourceOrBuilder

GetGlossaryRequestOrBuilder

GetSupportedLanguagesRequestOrBuilder

Glossary.LanguageCodePairOrBuilder

Glossary.LanguageCodesSetOrBuilder

GlossaryInputConfigOrBuilder

GlossaryOrBuilder

InputConfigOrBuilder

ListGlossariesRequestOrBuilder

ListGlossariesResponseOrBuilder

OutputConfigOrBuilder

SupportedLanguageOrBuilder

SupportedLanguagesOrBuilder

TranslateDocumentRequestOrBuilder

TranslateDocumentResponseOrBuilder

TranslateTextGlossaryConfigOrBuilder

TranslateTextRequestOrBuilder

TranslateTextResponseOrBuilder

TranslationOrBuilder

Enums

BatchDocumentInputConfig.SourceCase

BatchDocumentOutputConfig.DestinationCase

BatchTranslateDocumentMetadata.State

State of the job.

Protobuf enum google.cloud.translation.v3.BatchTranslateDocumentMetadata.State

BatchTranslateMetadata.State

State of the job.

Protobuf enum google.cloud.translation.v3.BatchTranslateMetadata.State

CreateGlossaryMetadata.State

Enumerates the possible states that the creation request can be in.

Protobuf enum google.cloud.translation.v3.CreateGlossaryMetadata.State

DeleteGlossaryMetadata.State

Enumerates the possible states that the creation request can be in.

Protobuf enum google.cloud.translation.v3.DeleteGlossaryMetadata.State

DetectLanguageRequest.SourceCase

DocumentInputConfig.SourceCase

DocumentOutputConfig.DestinationCase

Glossary.LanguagesCase

GlossaryInputConfig.SourceCase

InputConfig.SourceCase

OutputConfig.DestinationCase