Package com.google.cloud.translate.v3beta1 (2.3.5)

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()) {
   TranslateTextRequest request =
       TranslateTextRequest.newBuilder()
           .addAllContents(new ArrayList<String>())
           .setMimeType("mimeType-1392120434")
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .setTargetLanguageCode("targetLanguageCode-106414698")
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setModel("model104069929")
           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
           .putAllLabels(new HashMap<String, String>())
           .build();
   TranslateTextResponse response = translationServiceClient.translateText(request);
 }
 

Classes

BatchDocumentInputConfig

Input configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.BatchDocumentInputConfig

BatchDocumentInputConfig.Builder

Input configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.BatchDocumentInputConfig

BatchDocumentOutputConfig

Output configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.BatchDocumentOutputConfig

BatchDocumentOutputConfig.Builder

Output configuration for BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.BatchDocumentOutputConfig

BatchTranslateDocumentMetadata

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateDocumentMetadata

BatchTranslateDocumentMetadata.Builder

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateDocumentMetadata

BatchTranslateDocumentRequest

The BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateDocumentRequest

BatchTranslateDocumentRequest.Builder

The BatchTranslateDocument request.

Protobuf type google.cloud.translation.v3beta1.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.v3beta1.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.v3beta1.BatchTranslateDocumentResponse

BatchTranslateMetadata

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateMetadata

BatchTranslateMetadata.Builder

State metadata for the batch translation operation.

Protobuf type google.cloud.translation.v3beta1.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.v3beta1.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.v3beta1.BatchTranslateResponse

BatchTranslateTextRequest

The batch translation request.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateTextRequest

BatchTranslateTextRequest.Builder

The batch translation request.

Protobuf type google.cloud.translation.v3beta1.BatchTranslateTextRequest

CreateGlossaryMetadata

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

Protobuf type google.cloud.translation.v3beta1.CreateGlossaryMetadata

CreateGlossaryMetadata.Builder

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

Protobuf type google.cloud.translation.v3beta1.CreateGlossaryMetadata

CreateGlossaryRequest

Request message for CreateGlossary.

Protobuf type google.cloud.translation.v3beta1.CreateGlossaryRequest

CreateGlossaryRequest.Builder

Request message for CreateGlossary.

Protobuf type google.cloud.translation.v3beta1.CreateGlossaryRequest

DeleteGlossaryMetadata

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

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryMetadata

DeleteGlossaryMetadata.Builder

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

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryMetadata

DeleteGlossaryRequest

Request message for DeleteGlossary.

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryRequest

DeleteGlossaryRequest.Builder

Request message for DeleteGlossary.

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryRequest

DeleteGlossaryResponse

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

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryResponse

DeleteGlossaryResponse.Builder

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

Protobuf type google.cloud.translation.v3beta1.DeleteGlossaryResponse

DetectLanguageRequest

The request message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectLanguageRequest

DetectLanguageRequest.Builder

The request message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectLanguageRequest

DetectLanguageResponse

The response message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectLanguageResponse

DetectLanguageResponse.Builder

The response message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectLanguageResponse

DetectedLanguage

The response message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectedLanguage

DetectedLanguage.Builder

The response message for language detection.

Protobuf type google.cloud.translation.v3beta1.DetectedLanguage

DocumentInputConfig

A document translation request input config.

Protobuf type google.cloud.translation.v3beta1.DocumentInputConfig

DocumentInputConfig.Builder

A document translation request input config.

Protobuf type google.cloud.translation.v3beta1.DocumentInputConfig

DocumentOutputConfig

A document translation request output config.

Protobuf type google.cloud.translation.v3beta1.DocumentOutputConfig

DocumentOutputConfig.Builder

A document translation request output config.

Protobuf type google.cloud.translation.v3beta1.DocumentOutputConfig

DocumentTranslation

A translated document message.

Protobuf type google.cloud.translation.v3beta1.DocumentTranslation

DocumentTranslation.Builder

A translated document message.

Protobuf type google.cloud.translation.v3beta1.DocumentTranslation

GcsDestination

The Google Cloud Storage location for the output content.

Protobuf type google.cloud.translation.v3beta1.GcsDestination

GcsDestination.Builder

The Google Cloud Storage location for the output content.

Protobuf type google.cloud.translation.v3beta1.GcsDestination

GcsSource

The Google Cloud Storage location for the input content.

Protobuf type google.cloud.translation.v3beta1.GcsSource

GcsSource.Builder

The Google Cloud Storage location for the input content.

Protobuf type google.cloud.translation.v3beta1.GcsSource

GetGlossaryRequest

Request message for GetGlossary.

Protobuf type google.cloud.translation.v3beta1.GetGlossaryRequest

GetGlossaryRequest.Builder

Request message for GetGlossary.

Protobuf type google.cloud.translation.v3beta1.GetGlossaryRequest

GetSupportedLanguagesRequest

The request message for discovering supported languages.

Protobuf type google.cloud.translation.v3beta1.GetSupportedLanguagesRequest

GetSupportedLanguagesRequest.Builder

The request message for discovering supported languages.

Protobuf type google.cloud.translation.v3beta1.GetSupportedLanguagesRequest

Glossary

Represents a glossary built from user provided data.

Protobuf type google.cloud.translation.v3beta1.Glossary

Glossary.Builder

Represents a glossary built from user provided data.

Protobuf type google.cloud.translation.v3beta1.Glossary

Glossary.LanguageCodePair

Used with unidirectional glossaries.

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

Glossary.LanguageCodePair.Builder

Used with unidirectional glossaries.

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

Glossary.LanguageCodesSet

Used with equivalent term set glossaries.

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

Glossary.LanguageCodesSet.Builder

Used with equivalent term set glossaries.

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

GlossaryInputConfig

Input configuration for glossaries.

Protobuf type google.cloud.translation.v3beta1.GlossaryInputConfig

GlossaryInputConfig.Builder

Input configuration for glossaries.

Protobuf type google.cloud.translation.v3beta1.GlossaryInputConfig

GlossaryName

GlossaryName.Builder

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

InputConfig

Input configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3beta1.InputConfig

InputConfig.Builder

Input configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3beta1.InputConfig

ListGlossariesRequest

Request message for ListGlossaries.

Protobuf type google.cloud.translation.v3beta1.ListGlossariesRequest

ListGlossariesRequest.Builder

Request message for ListGlossaries.

Protobuf type google.cloud.translation.v3beta1.ListGlossariesRequest

ListGlossariesResponse

Response message for ListGlossaries.

Protobuf type google.cloud.translation.v3beta1.ListGlossariesResponse

ListGlossariesResponse.Builder

Response message for ListGlossaries.

Protobuf type google.cloud.translation.v3beta1.ListGlossariesResponse

LocationName

LocationName.Builder

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

OutputConfig

Output configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3beta1.OutputConfig

OutputConfig.Builder

Output configuration for BatchTranslateText request.

Protobuf type google.cloud.translation.v3beta1.OutputConfig

SupportedLanguage

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

Protobuf type google.cloud.translation.v3beta1.SupportedLanguage

SupportedLanguage.Builder

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

Protobuf type google.cloud.translation.v3beta1.SupportedLanguage

SupportedLanguages

The response message for discovering supported languages.

Protobuf type google.cloud.translation.v3beta1.SupportedLanguages

SupportedLanguages.Builder

The response message for discovering supported languages.

Protobuf type google.cloud.translation.v3beta1.SupportedLanguages

TranslateDocumentRequest

A document translation request.

Protobuf type google.cloud.translation.v3beta1.TranslateDocumentRequest

TranslateDocumentRequest.Builder

A document translation request.

Protobuf type google.cloud.translation.v3beta1.TranslateDocumentRequest

TranslateDocumentResponse

A translated document response message.

Protobuf type google.cloud.translation.v3beta1.TranslateDocumentResponse

TranslateDocumentResponse.Builder

A translated document response message.

Protobuf type google.cloud.translation.v3beta1.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.v3beta1.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.v3beta1.TranslateTextGlossaryConfig

TranslateTextRequest

The request message for synchronous translation.

Protobuf type google.cloud.translation.v3beta1.TranslateTextRequest

TranslateTextRequest.Builder

The request message for synchronous translation.

Protobuf type google.cloud.translation.v3beta1.TranslateTextRequest

TranslateTextResponse

Protobuf type google.cloud.translation.v3beta1.TranslateTextResponse

TranslateTextResponse.Builder

Protobuf type google.cloud.translation.v3beta1.TranslateTextResponse

Translation

A single translation response.

Protobuf type google.cloud.translation.v3beta1.Translation

Translation.Builder

A single translation response.

Protobuf type google.cloud.translation.v3beta1.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()) {
   TranslateTextRequest request =
       TranslateTextRequest.newBuilder()
           .addAllContents(new ArrayList<String>())
           .setMimeType("mimeType-1392120434")
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .setTargetLanguageCode("targetLanguageCode-106414698")
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setModel("model104069929")
           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
           .putAllLabels(new HashMap<String, String>())
           .build();
   TranslateTextResponse response = translationServiceClient.translateText(request);
 }
 

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.v3beta1.BatchTranslateDocumentMetadata.State

BatchTranslateMetadata.State

State of the job.

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

CreateGlossaryMetadata.State

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

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

DeleteGlossaryMetadata.State

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

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

DetectLanguageRequest.SourceCase

DocumentInputConfig.SourceCase

DocumentOutputConfig.DestinationCase

Glossary.LanguagesCase

GlossaryInputConfig.SourceCase

InputConfig.SourceCase

OutputConfig.DestinationCase