Class TranslationServiceClient (2.41.0)

GitHub RepositoryProduct ReferenceREST DocumentationRPC Documentation

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().

Methods
MethodDescriptionMethod Variants

TranslateText

Translates input text and returns translated text.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • translateText(TranslateTextRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • translateText(LocationName parent, String targetLanguageCode, List<String> contents)

  • translateText(String parent, String targetLanguageCode, List<String> contents)

  • translateText(LocationName parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

  • translateText(String parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • translateTextCallable()

DetectLanguage

Detects the language of text within a request.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • detectLanguage(DetectLanguageRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • detectLanguage(LocationName parent, String model, String mimeType, String content)

  • detectLanguage(String parent, String model, String mimeType, String content)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • detectLanguageCallable()

GetSupportedLanguages

Returns a list of supported languages for translation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSupportedLanguages(GetSupportedLanguagesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSupportedLanguages(LocationName parent, String model, String displayLanguageCode)

  • getSupportedLanguages(String parent, String model, String displayLanguageCode)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSupportedLanguagesCallable()

TranslateDocument

Translates documents in synchronous mode.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • translateDocument(TranslateDocumentRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • translateDocumentCallable()

BatchTranslateText

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchTranslateTextAsync(BatchTranslateTextRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchTranslateTextOperationCallable()

  • batchTranslateTextCallable()

BatchTranslateDocument

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchTranslateDocumentAsync(BatchTranslateDocumentRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • batchTranslateDocumentAsync(LocationName parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

  • batchTranslateDocumentAsync(String parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchTranslateDocumentOperationCallable()

  • batchTranslateDocumentCallable()

CreateGlossary

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createGlossaryAsync(CreateGlossaryRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createGlossaryAsync(LocationName parent, Glossary glossary)

  • createGlossaryAsync(String parent, Glossary glossary)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createGlossaryOperationCallable()

  • createGlossaryCallable()

ListGlossaries

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listGlossaries(ListGlossariesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listGlossaries(LocationName parent)

  • listGlossaries(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listGlossariesPagedCallable()

  • listGlossariesCallable()

GetGlossary

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getGlossary(GetGlossaryRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getGlossary(GlossaryName name)

  • getGlossary(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getGlossaryCallable()

DeleteGlossary

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteGlossaryAsync(DeleteGlossaryRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteGlossaryAsync(GlossaryName name)

  • deleteGlossaryAsync(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteGlossaryOperationCallable()

  • deleteGlossaryCallable()

CreateAdaptiveMtDataset

Creates an Adaptive MT dataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createAdaptiveMtDataset(CreateAdaptiveMtDatasetRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createAdaptiveMtDataset(LocationName parent, AdaptiveMtDataset adaptiveMtDataset)

  • createAdaptiveMtDataset(String parent, AdaptiveMtDataset adaptiveMtDataset)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createAdaptiveMtDatasetCallable()

DeleteAdaptiveMtDataset

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteAdaptiveMtDataset(DeleteAdaptiveMtDatasetRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteAdaptiveMtDataset(AdaptiveMtDatasetName name)

  • deleteAdaptiveMtDataset(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteAdaptiveMtDatasetCallable()

GetAdaptiveMtDataset

Gets the Adaptive MT dataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getAdaptiveMtDataset(GetAdaptiveMtDatasetRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getAdaptiveMtDataset(AdaptiveMtDatasetName name)

  • getAdaptiveMtDataset(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getAdaptiveMtDatasetCallable()

ListAdaptiveMtDatasets

Lists all Adaptive MT datasets for which the caller has read permission.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listAdaptiveMtDatasets(ListAdaptiveMtDatasetsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listAdaptiveMtDatasets(LocationName parent)

  • listAdaptiveMtDatasets(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listAdaptiveMtDatasetsPagedCallable()

  • listAdaptiveMtDatasetsCallable()

AdaptiveMtTranslate

Translate text using Adaptive MT.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • adaptiveMtTranslate(AdaptiveMtTranslateRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • adaptiveMtTranslate(LocationName parent, List<String> content)

  • adaptiveMtTranslate(String parent, List<String> content)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • adaptiveMtTranslateCallable()

GetAdaptiveMtFile

Gets and AdaptiveMtFile

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getAdaptiveMtFile(GetAdaptiveMtFileRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getAdaptiveMtFile(AdaptiveMtFileName name)

  • getAdaptiveMtFile(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getAdaptiveMtFileCallable()

DeleteAdaptiveMtFile

Deletes an AdaptiveMtFile along with its sentences.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteAdaptiveMtFile(DeleteAdaptiveMtFileRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteAdaptiveMtFile(AdaptiveMtFileName name)

  • deleteAdaptiveMtFile(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteAdaptiveMtFileCallable()

ImportAdaptiveMtFile

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • importAdaptiveMtFile(ImportAdaptiveMtFileRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • importAdaptiveMtFile(AdaptiveMtDatasetName parent)

  • importAdaptiveMtFile(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • importAdaptiveMtFileCallable()

ListAdaptiveMtFiles

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listAdaptiveMtFiles(ListAdaptiveMtFilesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listAdaptiveMtFiles(AdaptiveMtDatasetName parent)

  • listAdaptiveMtFiles(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listAdaptiveMtFilesPagedCallable()

  • listAdaptiveMtFilesCallable()

ListAdaptiveMtSentences

Lists all AdaptiveMtSentences under a given file/dataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listAdaptiveMtSentences(ListAdaptiveMtSentencesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listAdaptiveMtSentences(AdaptiveMtFileName parent)

  • listAdaptiveMtSentences(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listAdaptiveMtSentencesPagedCallable()

  • listAdaptiveMtSentencesCallable()

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.newHttpJsonBuilder().build();
 TranslationServiceClient translationServiceClient =
     TranslationServiceClient.create(translationServiceSettings);
 

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

Inheritance

java.lang.Object > TranslationServiceClient

Static Methods

create()

public static final TranslationServiceClient create()

Constructs an instance of TranslationServiceClient with default settings.

Returns
TypeDescription
TranslationServiceClient
Exceptions
TypeDescription
IOException

create(TranslationServiceSettings settings)

public static final TranslationServiceClient create(TranslationServiceSettings settings)

Constructs an instance of TranslationServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsTranslationServiceSettings
Returns
TypeDescription
TranslationServiceClient
Exceptions
TypeDescription
IOException

create(TranslationServiceStub stub)

public static final TranslationServiceClient create(TranslationServiceStub stub)

Constructs an instance of TranslationServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(TranslationServiceSettings).

Parameter
NameDescription
stubTranslationServiceStub
Returns
TypeDescription
TranslationServiceClient

Constructors

TranslationServiceClient(TranslationServiceSettings settings)

protected TranslationServiceClient(TranslationServiceSettings settings)

Constructs an instance of TranslationServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsTranslationServiceSettings

TranslationServiceClient(TranslationServiceStub stub)

protected TranslationServiceClient(TranslationServiceStub stub)
Parameter
NameDescription
stubTranslationServiceStub

Methods

adaptiveMtTranslate(AdaptiveMtTranslateRequest request)

public final AdaptiveMtTranslateResponse adaptiveMtTranslate(AdaptiveMtTranslateRequest request)

Translate text using Adaptive MT.

Sample code:


 // 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()) {
   AdaptiveMtTranslateRequest request =
       AdaptiveMtTranslateRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDataset(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .addAllContent(new ArrayList<String>())
           .build();
   AdaptiveMtTranslateResponse response = translationServiceClient.adaptiveMtTranslate(request);
 }
 
Parameter
NameDescription
requestAdaptiveMtTranslateRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
AdaptiveMtTranslateResponse

adaptiveMtTranslate(LocationName parent, List<String> content)

public final AdaptiveMtTranslateResponse adaptiveMtTranslate(LocationName parent, List<String> content)

Translate text using Adaptive MT.

Sample code:


 // 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]");
   List<String> content = new ArrayList<>();
   AdaptiveMtTranslateResponse response =
       translationServiceClient.adaptiveMtTranslate(parent, content);
 }
 
Parameters
NameDescription
parentLocationName

Required. Location to make a regional call.

Format: projects/{project-number-or-id}/locations/{location-id}.

contentList<String>

Required. The content of the input in string format. For now only one sentence per request is supported.

Returns
TypeDescription
AdaptiveMtTranslateResponse

adaptiveMtTranslate(String parent, List<String> content)

public final AdaptiveMtTranslateResponse adaptiveMtTranslate(String parent, List<String> content)

Translate text using Adaptive MT.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   List<String> content = new ArrayList<>();
   AdaptiveMtTranslateResponse response =
       translationServiceClient.adaptiveMtTranslate(parent, content);
 }
 
Parameters
NameDescription
parentString

Required. Location to make a regional call.

Format: projects/{project-number-or-id}/locations/{location-id}.

contentList<String>

Required. The content of the input in string format. For now only one sentence per request is supported.

Returns
TypeDescription
AdaptiveMtTranslateResponse

adaptiveMtTranslateCallable()

public final UnaryCallable<AdaptiveMtTranslateRequest,AdaptiveMtTranslateResponse> adaptiveMtTranslateCallable()

Translate text using Adaptive MT.

Sample code:


 // 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()) {
   AdaptiveMtTranslateRequest request =
       AdaptiveMtTranslateRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDataset(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .addAllContent(new ArrayList<String>())
           .build();
   ApiFuture<AdaptiveMtTranslateResponse> future =
       translationServiceClient.adaptiveMtTranslateCallable().futureCall(request);
   // Do something.
   AdaptiveMtTranslateResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<AdaptiveMtTranslateRequest,AdaptiveMtTranslateResponse>

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

batchTranslateDocumentAsync(BatchTranslateDocumentRequest request)

public final OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata> batchTranslateDocumentAsync(BatchTranslateDocumentRequest request)

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateDocumentRequest request =
       BatchTranslateDocumentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
           .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
           .putAllModels(new HashMap<String, String>())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllFormatConversions(new HashMap<String, String>())
           .setCustomizedAttribution("customizedAttribution557650238")
           .setEnableShadowRemovalNativePdf(true)
           .setEnableRotationCorrection(true)
           .build();
   BatchTranslateDocumentResponse response =
       translationServiceClient.batchTranslateDocumentAsync(request).get();
 }
 
Parameter
NameDescription
requestBatchTranslateDocumentRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata>

batchTranslateDocumentAsync(LocationName parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

public final OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata> batchTranslateDocumentAsync(LocationName parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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 sourceLanguageCode = "sourceLanguageCode1645917472";
   List<String> targetLanguageCodes = new ArrayList<>();
   List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
   BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
   BatchTranslateDocumentResponse response =
       translationServiceClient
           .batchTranslateDocumentAsync(
               parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
           .get();
 }
 
Parameters
NameDescription
parentLocationName

Required. Location to make a regional call.

Format: projects/{project-number-or-id}/locations/{location-id}.

The global location is not supported for batch translation.

Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

sourceLanguageCodeString

Required. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support.

targetLanguageCodesList<String>

Required. The ISO-639 language code to use for translation of the input document. Specify up to 10 language codes here.

inputConfigsList<BatchDocumentInputConfig>

Required. Input configurations. The total number of files matched should be <= 100. The total content size to translate should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.

outputConfigBatchDocumentOutputConfig

Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.

Returns
TypeDescription
OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata>

batchTranslateDocumentAsync(String parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

public final OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata> batchTranslateDocumentAsync(String parent, String sourceLanguageCode, List<String> targetLanguageCodes, List<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig)

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String sourceLanguageCode = "sourceLanguageCode1645917472";
   List<String> targetLanguageCodes = new ArrayList<>();
   List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
   BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
   BatchTranslateDocumentResponse response =
       translationServiceClient
           .batchTranslateDocumentAsync(
               parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
           .get();
 }
 
Parameters
NameDescription
parentString

Required. Location to make a regional call.

Format: projects/{project-number-or-id}/locations/{location-id}.

The global location is not supported for batch translation.

Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

sourceLanguageCodeString

Required. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support.

targetLanguageCodesList<String>

Required. The ISO-639 language code to use for translation of the input document. Specify up to 10 language codes here.

inputConfigsList<BatchDocumentInputConfig>

Required. Input configurations. The total number of files matched should be <= 100. The total content size to translate should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.

outputConfigBatchDocumentOutputConfig

Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.

Returns
TypeDescription
OperationFuture<BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata>

batchTranslateDocumentCallable()

public final UnaryCallable<BatchTranslateDocumentRequest,Operation> batchTranslateDocumentCallable()

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateDocumentRequest request =
       BatchTranslateDocumentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
           .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
           .putAllModels(new HashMap<String, String>())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllFormatConversions(new HashMap<String, String>())
           .setCustomizedAttribution("customizedAttribution557650238")
           .setEnableShadowRemovalNativePdf(true)
           .setEnableRotationCorrection(true)
           .build();
   ApiFuture<Operation> future =
       translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<BatchTranslateDocumentRequest,Operation>

batchTranslateDocumentOperationCallable()

public final OperationCallable<BatchTranslateDocumentRequest,BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata> batchTranslateDocumentOperationCallable()

Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateDocumentRequest request =
       BatchTranslateDocumentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
           .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
           .putAllModels(new HashMap<String, String>())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllFormatConversions(new HashMap<String, String>())
           .setCustomizedAttribution("customizedAttribution557650238")
           .setEnableShadowRemovalNativePdf(true)
           .setEnableRotationCorrection(true)
           .build();
   OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
       translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
   // Do something.
   BatchTranslateDocumentResponse response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<BatchTranslateDocumentRequest,BatchTranslateDocumentResponse,BatchTranslateDocumentMetadata>

batchTranslateTextAsync(BatchTranslateTextRequest request)

public final OperationFuture<BatchTranslateResponse,BatchTranslateMetadata> batchTranslateTextAsync(BatchTranslateTextRequest request)

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateTextRequest request =
       BatchTranslateTextRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .putAllModels(new HashMap<String, String>())
           .addAllInputConfigs(new ArrayList<InputConfig>())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllLabels(new HashMap<String, String>())
           .build();
   BatchTranslateResponse response =
       translationServiceClient.batchTranslateTextAsync(request).get();
 }
 
Parameter
NameDescription
requestBatchTranslateTextRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<BatchTranslateResponse,BatchTranslateMetadata>

batchTranslateTextCallable()

public final UnaryCallable<BatchTranslateTextRequest,Operation> batchTranslateTextCallable()

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateTextRequest request =
       BatchTranslateTextRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .putAllModels(new HashMap<String, String>())
           .addAllInputConfigs(new ArrayList<InputConfig>())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllLabels(new HashMap<String, String>())
           .build();
   ApiFuture<Operation> future =
       translationServiceClient.batchTranslateTextCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<BatchTranslateTextRequest,Operation>

batchTranslateTextOperationCallable()

public final OperationCallable<BatchTranslateTextRequest,BatchTranslateResponse,BatchTranslateMetadata> batchTranslateTextOperationCallable()

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.

This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Sample code:


 // 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()) {
   BatchTranslateTextRequest request =
       BatchTranslateTextRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .addAllTargetLanguageCodes(new ArrayList<String>())
           .putAllModels(new HashMap<String, String>())
           .addAllInputConfigs(new ArrayList<InputConfig>())
           .setOutputConfig(OutputConfig.newBuilder().build())
           .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
           .putAllLabels(new HashMap<String, String>())
           .build();
   OperationFuture<BatchTranslateResponse, BatchTranslateMetadata> future =
       translationServiceClient.batchTranslateTextOperationCallable().futureCall(request);
   // Do something.
   BatchTranslateResponse response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<BatchTranslateTextRequest,BatchTranslateResponse,BatchTranslateMetadata>

close()

public final void close()

createAdaptiveMtDataset(CreateAdaptiveMtDatasetRequest request)

public final AdaptiveMtDataset createAdaptiveMtDataset(CreateAdaptiveMtDatasetRequest request)

Creates an Adaptive MT dataset.

Sample code:


 // 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()) {
   CreateAdaptiveMtDatasetRequest request =
       CreateAdaptiveMtDatasetRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setAdaptiveMtDataset(AdaptiveMtDataset.newBuilder().build())
           .build();
   AdaptiveMtDataset response = translationServiceClient.createAdaptiveMtDataset(request);
 }
 
Parameter
NameDescription
requestCreateAdaptiveMtDatasetRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
AdaptiveMtDataset

createAdaptiveMtDataset(LocationName parent, AdaptiveMtDataset adaptiveMtDataset)

public final AdaptiveMtDataset createAdaptiveMtDataset(LocationName parent, AdaptiveMtDataset adaptiveMtDataset)

Creates an Adaptive MT dataset.

Sample code:


 // 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]");
   AdaptiveMtDataset adaptiveMtDataset = AdaptiveMtDataset.newBuilder().build();
   AdaptiveMtDataset response =
       translationServiceClient.createAdaptiveMtDataset(parent, adaptiveMtDataset);
 }
 
Parameters
NameDescription
parentLocationName

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

adaptiveMtDatasetAdaptiveMtDataset

Required. The AdaptiveMtDataset to be created.

Returns
TypeDescription
AdaptiveMtDataset

createAdaptiveMtDataset(String parent, AdaptiveMtDataset adaptiveMtDataset)

public final AdaptiveMtDataset createAdaptiveMtDataset(String parent, AdaptiveMtDataset adaptiveMtDataset)

Creates an Adaptive MT dataset.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   AdaptiveMtDataset adaptiveMtDataset = AdaptiveMtDataset.newBuilder().build();
   AdaptiveMtDataset response =
       translationServiceClient.createAdaptiveMtDataset(parent, adaptiveMtDataset);
 }
 
Parameters
NameDescription
parentString

Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}

adaptiveMtDatasetAdaptiveMtDataset

Required. The AdaptiveMtDataset to be created.

Returns
TypeDescription
AdaptiveMtDataset

createAdaptiveMtDatasetCallable()

public final UnaryCallable<CreateAdaptiveMtDatasetRequest,AdaptiveMtDataset> createAdaptiveMtDatasetCallable()

Creates an Adaptive MT dataset.

Sample code:


 // 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()) {
   CreateAdaptiveMtDatasetRequest request =
       CreateAdaptiveMtDatasetRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setAdaptiveMtDataset(AdaptiveMtDataset.newBuilder().build())
           .build();
   ApiFuture<AdaptiveMtDataset> future =
       translationServiceClient.createAdaptiveMtDatasetCallable().futureCall(request);
   // Do something.
   AdaptiveMtDataset response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateAdaptiveMtDatasetRequest,AdaptiveMtDataset>

createGlossaryAsync(CreateGlossaryRequest request)

public final OperationFuture<Glossary,CreateGlossaryMetadata> createGlossaryAsync(CreateGlossaryRequest request)

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   CreateGlossaryRequest request =
       CreateGlossaryRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setGlossary(Glossary.newBuilder().build())
           .build();
   Glossary response = translationServiceClient.createGlossaryAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateGlossaryRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Glossary,CreateGlossaryMetadata>

createGlossaryAsync(LocationName parent, Glossary glossary)

public final OperationFuture<Glossary,CreateGlossaryMetadata> createGlossaryAsync(LocationName parent, Glossary glossary)

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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]");
   Glossary glossary = Glossary.newBuilder().build();
   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The project name.

glossaryGlossary

Required. The glossary to create.

Returns
TypeDescription
OperationFuture<Glossary,CreateGlossaryMetadata>

createGlossaryAsync(String parent, Glossary glossary)

public final OperationFuture<Glossary,CreateGlossaryMetadata> createGlossaryAsync(String parent, Glossary glossary)

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Glossary glossary = Glossary.newBuilder().build();
   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
 }
 
Parameters
NameDescription
parentString

Required. The project name.

glossaryGlossary

Required. The glossary to create.

Returns
TypeDescription
OperationFuture<Glossary,CreateGlossaryMetadata>

createGlossaryCallable()

public final UnaryCallable<CreateGlossaryRequest,Operation> createGlossaryCallable()

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   CreateGlossaryRequest request =
       CreateGlossaryRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setGlossary(Glossary.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       translationServiceClient.createGlossaryCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateGlossaryRequest,Operation>

createGlossaryOperationCallable()

public final OperationCallable<CreateGlossaryRequest,Glossary,CreateGlossaryMetadata> createGlossaryOperationCallable()

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   CreateGlossaryRequest request =
       CreateGlossaryRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setGlossary(Glossary.newBuilder().build())
           .build();
   OperationFuture<Glossary, CreateGlossaryMetadata> future =
       translationServiceClient.createGlossaryOperationCallable().futureCall(request);
   // Do something.
   Glossary response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateGlossaryRequest,Glossary,CreateGlossaryMetadata>

deleteAdaptiveMtDataset(AdaptiveMtDatasetName name)

public final void deleteAdaptiveMtDataset(AdaptiveMtDatasetName name)

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Sample code:


 // 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()) {
   AdaptiveMtDatasetName name = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   translationServiceClient.deleteAdaptiveMtDataset(name);
 }
 
Parameter
NameDescription
nameAdaptiveMtDatasetName

Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

deleteAdaptiveMtDataset(DeleteAdaptiveMtDatasetRequest request)

public final void deleteAdaptiveMtDataset(DeleteAdaptiveMtDatasetRequest request)

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Sample code:


 // 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()) {
   DeleteAdaptiveMtDatasetRequest request =
       DeleteAdaptiveMtDatasetRequest.newBuilder()
           .setName(AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   translationServiceClient.deleteAdaptiveMtDataset(request);
 }
 
Parameter
NameDescription
requestDeleteAdaptiveMtDatasetRequest

The request object containing all of the parameters for the API call.

deleteAdaptiveMtDataset(String name)

public final void deleteAdaptiveMtDataset(String name)

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Sample code:


 // 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()) {
   String name = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   translationServiceClient.deleteAdaptiveMtDataset(name);
 }
 
Parameter
NameDescription
nameString

Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

deleteAdaptiveMtDatasetCallable()

public final UnaryCallable<DeleteAdaptiveMtDatasetRequest,Empty> deleteAdaptiveMtDatasetCallable()

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Sample code:


 // 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()) {
   DeleteAdaptiveMtDatasetRequest request =
       DeleteAdaptiveMtDatasetRequest.newBuilder()
           .setName(AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   ApiFuture<Empty> future =
       translationServiceClient.deleteAdaptiveMtDatasetCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteAdaptiveMtDatasetRequest,Empty>

deleteAdaptiveMtFile(AdaptiveMtFileName name)

public final void deleteAdaptiveMtFile(AdaptiveMtFileName name)

Deletes an AdaptiveMtFile along with its sentences.

Sample code:


 // 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()) {
   AdaptiveMtFileName name =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]");
   translationServiceClient.deleteAdaptiveMtFile(name);
 }
 
Parameter
NameDescription
nameAdaptiveMtFileName

Required. The resource name of the file to delete, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

deleteAdaptiveMtFile(DeleteAdaptiveMtFileRequest request)

public final void deleteAdaptiveMtFile(DeleteAdaptiveMtFileRequest request)

Deletes an AdaptiveMtFile along with its sentences.

Sample code:


 // 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()) {
   DeleteAdaptiveMtFileRequest request =
       DeleteAdaptiveMtFileRequest.newBuilder()
           .setName(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .build();
   translationServiceClient.deleteAdaptiveMtFile(request);
 }
 
Parameter
NameDescription
requestDeleteAdaptiveMtFileRequest

The request object containing all of the parameters for the API call.

deleteAdaptiveMtFile(String name)

public final void deleteAdaptiveMtFile(String name)

Deletes an AdaptiveMtFile along with its sentences.

Sample code:


 // 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()) {
   String name =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]").toString();
   translationServiceClient.deleteAdaptiveMtFile(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the file to delete, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

deleteAdaptiveMtFileCallable()

public final UnaryCallable<DeleteAdaptiveMtFileRequest,Empty> deleteAdaptiveMtFileCallable()

Deletes an AdaptiveMtFile along with its sentences.

Sample code:


 // 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()) {
   DeleteAdaptiveMtFileRequest request =
       DeleteAdaptiveMtFileRequest.newBuilder()
           .setName(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .build();
   ApiFuture<Empty> future =
       translationServiceClient.deleteAdaptiveMtFileCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteAdaptiveMtFileRequest,Empty>

deleteGlossaryAsync(DeleteGlossaryRequest request)

public final OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata> deleteGlossaryAsync(DeleteGlossaryRequest request)

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   DeleteGlossaryRequest request =
       DeleteGlossaryRequest.newBuilder()
           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
           .build();
   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteGlossaryRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata>

deleteGlossaryAsync(GlossaryName name)

public final OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata> deleteGlossaryAsync(GlossaryName name)

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
 }
 
Parameter
NameDescription
nameGlossaryName

Required. The name of the glossary to delete.

Returns
TypeDescription
OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata>

deleteGlossaryAsync(String name)

public final OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata> deleteGlossaryAsync(String name)

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The name of the glossary to delete.

Returns
TypeDescription
OperationFuture<DeleteGlossaryResponse,DeleteGlossaryMetadata>

deleteGlossaryCallable()

public final UnaryCallable<DeleteGlossaryRequest,Operation> deleteGlossaryCallable()

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   DeleteGlossaryRequest request =
       DeleteGlossaryRequest.newBuilder()
           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
           .build();
   ApiFuture<Operation> future =
       translationServiceClient.deleteGlossaryCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteGlossaryRequest,Operation>

deleteGlossaryOperationCallable()

public final OperationCallable<DeleteGlossaryRequest,DeleteGlossaryResponse,DeleteGlossaryMetadata> deleteGlossaryOperationCallable()

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   DeleteGlossaryRequest request =
       DeleteGlossaryRequest.newBuilder()
           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
           .build();
   OperationFuture<DeleteGlossaryResponse, DeleteGlossaryMetadata> future =
       translationServiceClient.deleteGlossaryOperationCallable().futureCall(request);
   // Do something.
   DeleteGlossaryResponse response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteGlossaryRequest,DeleteGlossaryResponse,DeleteGlossaryMetadata>

detectLanguage(DetectLanguageRequest request)

public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request)

Detects the language of text within a request.

Sample code:


 // 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()) {
   DetectLanguageRequest request =
       DetectLanguageRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setModel("model104069929")
           .setMimeType("mimeType-1392120434")
           .putAllLabels(new HashMap<String, String>())
           .build();
   DetectLanguageResponse response = translationServiceClient.detectLanguage(request);
 }
 
Parameter
NameDescription
requestDetectLanguageRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DetectLanguageResponse

detectLanguage(LocationName parent, String model, String mimeType, String content)

public final DetectLanguageResponse detectLanguage(LocationName parent, String model, String mimeType, String content)

Detects the language of text within a request.

Sample code:


 // 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 model = "model104069929";
   String mimeType = "mimeType-1392120434";
   String content = "content951530617";
   DetectLanguageResponse response =
       translationServiceClient.detectLanguage(parent, model, mimeType, content);
 }
 
Parameters
NameDescription
parentLocationName

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id}/locations/{location-id} or projects/{project-number-or-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. The language detection model to be used.

Format: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}

Only one language detection model is currently supported: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default.

If not specified, the default model is used.

mimeTypeString

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

contentString

The content of the input stored as a string.

Returns
TypeDescription
DetectLanguageResponse

detectLanguage(String parent, String model, String mimeType, String content)

public final DetectLanguageResponse detectLanguage(String parent, String model, String mimeType, String content)

Detects the language of text within a request.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String model = "model104069929";
   String mimeType = "mimeType-1392120434";
   String content = "content951530617";
   DetectLanguageResponse response =
       translationServiceClient.detectLanguage(parent, model, mimeType, content);
 }
 
Parameters
NameDescription
parentString

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id}/locations/{location-id} or projects/{project-number-or-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. The language detection model to be used.

Format: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}

Only one language detection model is currently supported: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default.

If not specified, the default model is used.

mimeTypeString

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

contentString

The content of the input stored as a string.

Returns
TypeDescription
DetectLanguageResponse

detectLanguageCallable()

public final UnaryCallable<DetectLanguageRequest,DetectLanguageResponse> detectLanguageCallable()

Detects the language of text within a request.

Sample code:


 // 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()) {
   DetectLanguageRequest request =
       DetectLanguageRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setModel("model104069929")
           .setMimeType("mimeType-1392120434")
           .putAllLabels(new HashMap<String, String>())
           .build();
   ApiFuture<DetectLanguageResponse> future =
       translationServiceClient.detectLanguageCallable().futureCall(request);
   // Do something.
   DetectLanguageResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DetectLanguageRequest,DetectLanguageResponse>

getAdaptiveMtDataset(AdaptiveMtDatasetName name)

public final AdaptiveMtDataset getAdaptiveMtDataset(AdaptiveMtDatasetName name)

Gets the Adaptive MT dataset.

Sample code:


 // 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()) {
   AdaptiveMtDatasetName name = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   AdaptiveMtDataset response = translationServiceClient.getAdaptiveMtDataset(name);
 }
 
Parameter
NameDescription
nameAdaptiveMtDatasetName

Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

Returns
TypeDescription
AdaptiveMtDataset

getAdaptiveMtDataset(GetAdaptiveMtDatasetRequest request)

public final AdaptiveMtDataset getAdaptiveMtDataset(GetAdaptiveMtDatasetRequest request)

Gets the Adaptive MT dataset.

Sample code:


 // 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()) {
   GetAdaptiveMtDatasetRequest request =
       GetAdaptiveMtDatasetRequest.newBuilder()
           .setName(AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   AdaptiveMtDataset response = translationServiceClient.getAdaptiveMtDataset(request);
 }
 
Parameter
NameDescription
requestGetAdaptiveMtDatasetRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
AdaptiveMtDataset

getAdaptiveMtDataset(String name)

public final AdaptiveMtDataset getAdaptiveMtDataset(String name)

Gets the Adaptive MT dataset.

Sample code:


 // 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()) {
   String name = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   AdaptiveMtDataset response = translationServiceClient.getAdaptiveMtDataset(name);
 }
 
Parameter
NameDescription
nameString

Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}

Returns
TypeDescription
AdaptiveMtDataset

getAdaptiveMtDatasetCallable()

public final UnaryCallable<GetAdaptiveMtDatasetRequest,AdaptiveMtDataset> getAdaptiveMtDatasetCallable()

Gets the Adaptive MT dataset.

Sample code:


 // 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()) {
   GetAdaptiveMtDatasetRequest request =
       GetAdaptiveMtDatasetRequest.newBuilder()
           .setName(AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   ApiFuture<AdaptiveMtDataset> future =
       translationServiceClient.getAdaptiveMtDatasetCallable().futureCall(request);
   // Do something.
   AdaptiveMtDataset response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetAdaptiveMtDatasetRequest,AdaptiveMtDataset>

getAdaptiveMtFile(AdaptiveMtFileName name)

public final AdaptiveMtFile getAdaptiveMtFile(AdaptiveMtFileName name)

Gets and AdaptiveMtFile

Sample code:


 // 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()) {
   AdaptiveMtFileName name =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]");
   AdaptiveMtFile response = translationServiceClient.getAdaptiveMtFile(name);
 }
 
Parameter
NameDescription
nameAdaptiveMtFileName

Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

Returns
TypeDescription
AdaptiveMtFile

getAdaptiveMtFile(GetAdaptiveMtFileRequest request)

public final AdaptiveMtFile getAdaptiveMtFile(GetAdaptiveMtFileRequest request)

Gets and AdaptiveMtFile

Sample code:


 // 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()) {
   GetAdaptiveMtFileRequest request =
       GetAdaptiveMtFileRequest.newBuilder()
           .setName(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .build();
   AdaptiveMtFile response = translationServiceClient.getAdaptiveMtFile(request);
 }
 
Parameter
NameDescription
requestGetAdaptiveMtFileRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
AdaptiveMtFile

getAdaptiveMtFile(String name)

public final AdaptiveMtFile getAdaptiveMtFile(String name)

Gets and AdaptiveMtFile

Sample code:


 // 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()) {
   String name =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]").toString();
   AdaptiveMtFile response = translationServiceClient.getAdaptiveMtFile(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}

Returns
TypeDescription
AdaptiveMtFile

getAdaptiveMtFileCallable()

public final UnaryCallable<GetAdaptiveMtFileRequest,AdaptiveMtFile> getAdaptiveMtFileCallable()

Gets and AdaptiveMtFile

Sample code:


 // 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()) {
   GetAdaptiveMtFileRequest request =
       GetAdaptiveMtFileRequest.newBuilder()
           .setName(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .build();
   ApiFuture<AdaptiveMtFile> future =
       translationServiceClient.getAdaptiveMtFileCallable().futureCall(request);
   // Do something.
   AdaptiveMtFile response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetAdaptiveMtFileRequest,AdaptiveMtFile>

getGlossary(GetGlossaryRequest request)

public final Glossary getGlossary(GetGlossaryRequest request)

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   GetGlossaryRequest request =
       GetGlossaryRequest.newBuilder()
           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
           .build();
   Glossary response = translationServiceClient.getGlossary(request);
 }
 
Parameter
NameDescription
requestGetGlossaryRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Glossary

getGlossary(GlossaryName name)

public final Glossary getGlossary(GlossaryName name)

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
   Glossary response = translationServiceClient.getGlossary(name);
 }
 
Parameter
NameDescription
nameGlossaryName

Required. The name of the glossary to retrieve.

Returns
TypeDescription
Glossary

getGlossary(String name)

public final Glossary getGlossary(String name)

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
   Glossary response = translationServiceClient.getGlossary(name);
 }
 
Parameter
NameDescription
nameString

Required. The name of the glossary to retrieve.

Returns
TypeDescription
Glossary

getGlossaryCallable()

public final UnaryCallable<GetGlossaryRequest,Glossary> getGlossaryCallable()

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:


 // 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()) {
   GetGlossaryRequest request =
       GetGlossaryRequest.newBuilder()
           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
           .build();
   ApiFuture<Glossary> future =
       translationServiceClient.getGlossaryCallable().futureCall(request);
   // Do something.
   Glossary response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetGlossaryRequest,Glossary>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getSettings()

public final TranslationServiceSettings getSettings()
Returns
TypeDescription
TranslationServiceSettings

getStub()

public TranslationServiceStub getStub()
Returns
TypeDescription
TranslationServiceStub

getSupportedLanguages(GetSupportedLanguagesRequest request)

public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesRequest request)

Returns a list of supported languages for translation.

Sample code:


 // 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()) {
   GetSupportedLanguagesRequest request =
       GetSupportedLanguagesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDisplayLanguageCode("displayLanguageCode-1457478841")
           .setModel("model104069929")
           .build();
   SupportedLanguages response = translationServiceClient.getSupportedLanguages(request);
 }
 
Parameter
NameDescription
requestGetSupportedLanguagesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
SupportedLanguages

getSupportedLanguages(LocationName parent, String model, String displayLanguageCode)

public final SupportedLanguages getSupportedLanguages(LocationName parent, String model, String displayLanguageCode)

Returns a list of supported languages for translation.

Sample code:


 // 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 model = "model104069929";
   String displayLanguageCode = "displayLanguageCode-1457478841";
   SupportedLanguages response =
       translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode);
 }
 
Parameters
NameDescription
parentLocationName

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for AutoML models.

Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. Get supported languages of this model.

The format depends on model type:

- AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

- General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

Returns languages supported by the specified model. If missing, we get supported languages of Google general NMT model.

displayLanguageCodeString

Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response.

Returns
TypeDescription
SupportedLanguages

getSupportedLanguages(String parent, String model, String displayLanguageCode)

public final SupportedLanguages getSupportedLanguages(String parent, String model, String displayLanguageCode)

Returns a list of supported languages for translation.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String model = "model104069929";
   String displayLanguageCode = "displayLanguageCode-1457478841";
   SupportedLanguages response =
       translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode);
 }
 
Parameters
NameDescription
parentString

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for AutoML models.

Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. Get supported languages of this model.

The format depends on model type:

- AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

- General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

Returns languages supported by the specified model. If missing, we get supported languages of Google general NMT model.

displayLanguageCodeString

Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response.

Returns
TypeDescription
SupportedLanguages

getSupportedLanguagesCallable()

public final UnaryCallable<GetSupportedLanguagesRequest,SupportedLanguages> getSupportedLanguagesCallable()

Returns a list of supported languages for translation.

Sample code:


 // 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()) {
   GetSupportedLanguagesRequest request =
       GetSupportedLanguagesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setDisplayLanguageCode("displayLanguageCode-1457478841")
           .setModel("model104069929")
           .build();
   ApiFuture<SupportedLanguages> future =
       translationServiceClient.getSupportedLanguagesCallable().futureCall(request);
   // Do something.
   SupportedLanguages response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetSupportedLanguagesRequest,SupportedLanguages>

importAdaptiveMtFile(AdaptiveMtDatasetName parent)

public final ImportAdaptiveMtFileResponse importAdaptiveMtFile(AdaptiveMtDatasetName parent)

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Sample code:


 // 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()) {
   AdaptiveMtDatasetName parent =
       AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   ImportAdaptiveMtFileResponse response = translationServiceClient.importAdaptiveMtFile(parent);
 }
 
Parameter
NameDescription
parentAdaptiveMtDatasetName

Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
ImportAdaptiveMtFileResponse

importAdaptiveMtFile(ImportAdaptiveMtFileRequest request)

public final ImportAdaptiveMtFileResponse importAdaptiveMtFile(ImportAdaptiveMtFileRequest request)

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Sample code:


 // 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()) {
   ImportAdaptiveMtFileRequest request =
       ImportAdaptiveMtFileRequest.newBuilder()
           .setParent(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   ImportAdaptiveMtFileResponse response =
       translationServiceClient.importAdaptiveMtFile(request);
 }
 
Parameter
NameDescription
requestImportAdaptiveMtFileRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ImportAdaptiveMtFileResponse

importAdaptiveMtFile(String parent)

public final ImportAdaptiveMtFileResponse importAdaptiveMtFile(String parent)

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Sample code:


 // 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()) {
   String parent = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   ImportAdaptiveMtFileResponse response = translationServiceClient.importAdaptiveMtFile(parent);
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
ImportAdaptiveMtFileResponse

importAdaptiveMtFileCallable()

public final UnaryCallable<ImportAdaptiveMtFileRequest,ImportAdaptiveMtFileResponse> importAdaptiveMtFileCallable()

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Sample code:


 // 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()) {
   ImportAdaptiveMtFileRequest request =
       ImportAdaptiveMtFileRequest.newBuilder()
           .setParent(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .build();
   ApiFuture<ImportAdaptiveMtFileResponse> future =
       translationServiceClient.importAdaptiveMtFileCallable().futureCall(request);
   // Do something.
   ImportAdaptiveMtFileResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<ImportAdaptiveMtFileRequest,ImportAdaptiveMtFileResponse>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listAdaptiveMtDatasets(ListAdaptiveMtDatasetsRequest request)

public final TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse listAdaptiveMtDatasets(ListAdaptiveMtDatasetsRequest request)

Lists all Adaptive MT datasets for which the caller has read permission.

Sample code:


 // 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()) {
   ListAdaptiveMtDatasetsRequest request =
       ListAdaptiveMtDatasetsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (AdaptiveMtDataset element :
       translationServiceClient.listAdaptiveMtDatasets(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListAdaptiveMtDatasetsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse

listAdaptiveMtDatasets(LocationName parent)

public final TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse listAdaptiveMtDatasets(LocationName parent)

Lists all Adaptive MT datasets for which the caller has read permission.

Sample code:


 // 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]");
   for (AdaptiveMtDataset element :
       translationServiceClient.listAdaptiveMtDatasets(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse

listAdaptiveMtDatasets(String parent)

public final TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse listAdaptiveMtDatasets(String parent)

Lists all Adaptive MT datasets for which the caller has read permission.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (AdaptiveMtDataset element :
       translationServiceClient.listAdaptiveMtDatasets(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse

listAdaptiveMtDatasetsCallable()

public final UnaryCallable<ListAdaptiveMtDatasetsRequest,ListAdaptiveMtDatasetsResponse> listAdaptiveMtDatasetsCallable()

Lists all Adaptive MT datasets for which the caller has read permission.

Sample code:


 // 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()) {
   ListAdaptiveMtDatasetsRequest request =
       ListAdaptiveMtDatasetsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListAdaptiveMtDatasetsResponse response =
         translationServiceClient.listAdaptiveMtDatasetsCallable().call(request);
     for (AdaptiveMtDataset element : response.getAdaptiveMtDatasetsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtDatasetsRequest,ListAdaptiveMtDatasetsResponse>

listAdaptiveMtDatasetsPagedCallable()

public final UnaryCallable<ListAdaptiveMtDatasetsRequest,TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse> listAdaptiveMtDatasetsPagedCallable()

Lists all Adaptive MT datasets for which the caller has read permission.

Sample code:


 // 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()) {
   ListAdaptiveMtDatasetsRequest request =
       ListAdaptiveMtDatasetsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<AdaptiveMtDataset> future =
       translationServiceClient.listAdaptiveMtDatasetsPagedCallable().futureCall(request);
   // Do something.
   for (AdaptiveMtDataset element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtDatasetsRequest,ListAdaptiveMtDatasetsPagedResponse>

listAdaptiveMtFiles(AdaptiveMtDatasetName parent)

public final TranslationServiceClient.ListAdaptiveMtFilesPagedResponse listAdaptiveMtFiles(AdaptiveMtDatasetName parent)

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Sample code:


 // 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()) {
   AdaptiveMtDatasetName parent =
       AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]");
   for (AdaptiveMtFile element :
       translationServiceClient.listAdaptiveMtFiles(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentAdaptiveMtDatasetName

Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtFilesPagedResponse

listAdaptiveMtFiles(ListAdaptiveMtFilesRequest request)

public final TranslationServiceClient.ListAdaptiveMtFilesPagedResponse listAdaptiveMtFiles(ListAdaptiveMtFilesRequest request)

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Sample code:


 // 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()) {
   ListAdaptiveMtFilesRequest request =
       ListAdaptiveMtFilesRequest.newBuilder()
           .setParent(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (AdaptiveMtFile element :
       translationServiceClient.listAdaptiveMtFiles(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListAdaptiveMtFilesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtFilesPagedResponse

listAdaptiveMtFiles(String parent)

public final TranslationServiceClient.ListAdaptiveMtFilesPagedResponse listAdaptiveMtFiles(String parent)

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Sample code:


 // 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()) {
   String parent = AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString();
   for (AdaptiveMtFile element :
       translationServiceClient.listAdaptiveMtFiles(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtFilesPagedResponse

listAdaptiveMtFilesCallable()

public final UnaryCallable<ListAdaptiveMtFilesRequest,ListAdaptiveMtFilesResponse> listAdaptiveMtFilesCallable()

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Sample code:


 // 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()) {
   ListAdaptiveMtFilesRequest request =
       ListAdaptiveMtFilesRequest.newBuilder()
           .setParent(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListAdaptiveMtFilesResponse response =
         translationServiceClient.listAdaptiveMtFilesCallable().call(request);
     for (AdaptiveMtFile element : response.getAdaptiveMtFilesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtFilesRequest,ListAdaptiveMtFilesResponse>

listAdaptiveMtFilesPagedCallable()

public final UnaryCallable<ListAdaptiveMtFilesRequest,TranslationServiceClient.ListAdaptiveMtFilesPagedResponse> listAdaptiveMtFilesPagedCallable()

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Sample code:


 // 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()) {
   ListAdaptiveMtFilesRequest request =
       ListAdaptiveMtFilesRequest.newBuilder()
           .setParent(
               AdaptiveMtDatasetName.of("[PROJECT]", "[LOCATION]", "[DATASET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<AdaptiveMtFile> future =
       translationServiceClient.listAdaptiveMtFilesPagedCallable().futureCall(request);
   // Do something.
   for (AdaptiveMtFile element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtFilesRequest,ListAdaptiveMtFilesPagedResponse>

listAdaptiveMtSentences(AdaptiveMtFileName parent)

public final TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse listAdaptiveMtSentences(AdaptiveMtFileName parent)

Lists all AdaptiveMtSentences under a given file/dataset.

Sample code:


 // 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()) {
   AdaptiveMtFileName parent =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]");
   for (AdaptiveMtSentence element :
       translationServiceClient.listAdaptiveMtSentences(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentAdaptiveMtFileName

Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse

listAdaptiveMtSentences(ListAdaptiveMtSentencesRequest request)

public final TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse listAdaptiveMtSentences(ListAdaptiveMtSentencesRequest request)

Lists all AdaptiveMtSentences under a given file/dataset.

Sample code:


 // 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()) {
   ListAdaptiveMtSentencesRequest request =
       ListAdaptiveMtSentencesRequest.newBuilder()
           .setParent(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (AdaptiveMtSentence element :
       translationServiceClient.listAdaptiveMtSentences(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListAdaptiveMtSentencesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse

listAdaptiveMtSentences(String parent)

public final TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse listAdaptiveMtSentences(String parent)

Lists all AdaptiveMtSentences under a given file/dataset.

Sample code:


 // 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()) {
   String parent =
       AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]").toString();
   for (AdaptiveMtSentence element :
       translationServiceClient.listAdaptiveMtSentences(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}

Returns
TypeDescription
TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse

listAdaptiveMtSentencesCallable()

public final UnaryCallable<ListAdaptiveMtSentencesRequest,ListAdaptiveMtSentencesResponse> listAdaptiveMtSentencesCallable()

Lists all AdaptiveMtSentences under a given file/dataset.

Sample code:


 // 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()) {
   ListAdaptiveMtSentencesRequest request =
       ListAdaptiveMtSentencesRequest.newBuilder()
           .setParent(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListAdaptiveMtSentencesResponse response =
         translationServiceClient.listAdaptiveMtSentencesCallable().call(request);
     for (AdaptiveMtSentence element : response.getAdaptiveMtSentencesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtSentencesRequest,ListAdaptiveMtSentencesResponse>

listAdaptiveMtSentencesPagedCallable()

public final UnaryCallable<ListAdaptiveMtSentencesRequest,TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse> listAdaptiveMtSentencesPagedCallable()

Lists all AdaptiveMtSentences under a given file/dataset.

Sample code:


 // 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()) {
   ListAdaptiveMtSentencesRequest request =
       ListAdaptiveMtSentencesRequest.newBuilder()
           .setParent(
               AdaptiveMtFileName.of("[PROJECT]", "[LOCATION]", "[DATASET]", "[FILE]")
                   .toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<AdaptiveMtSentence> future =
       translationServiceClient.listAdaptiveMtSentencesPagedCallable().futureCall(request);
   // Do something.
   for (AdaptiveMtSentence element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAdaptiveMtSentencesRequest,ListAdaptiveMtSentencesPagedResponse>

listGlossaries(ListGlossariesRequest request)

public final TranslationServiceClient.ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest request)

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   ListGlossariesRequest request =
       ListGlossariesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListGlossariesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslationServiceClient.ListGlossariesPagedResponse

listGlossaries(LocationName parent)

public final TranslationServiceClient.ListGlossariesPagedResponse listGlossaries(LocationName parent)

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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]");
   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The name of the project from which to list all of the glossaries.

Returns
TypeDescription
TranslationServiceClient.ListGlossariesPagedResponse

listGlossaries(String parent)

public final TranslationServiceClient.ListGlossariesPagedResponse listGlossaries(String parent)

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The name of the project from which to list all of the glossaries.

Returns
TypeDescription
TranslationServiceClient.ListGlossariesPagedResponse

listGlossariesCallable()

public final UnaryCallable<ListGlossariesRequest,ListGlossariesResponse> listGlossariesCallable()

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   ListGlossariesRequest request =
       ListGlossariesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListGlossariesResponse response =
         translationServiceClient.listGlossariesCallable().call(request);
     for (Glossary element : response.getGlossariesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListGlossariesRequest,ListGlossariesResponse>

listGlossariesPagedCallable()

public final UnaryCallable<ListGlossariesRequest,TranslationServiceClient.ListGlossariesPagedResponse> listGlossariesPagedCallable()

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:


 // 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()) {
   ListGlossariesRequest request =
       ListGlossariesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Glossary> future =
       translationServiceClient.listGlossariesPagedCallable().futureCall(request);
   // Do something.
   for (Glossary element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListGlossariesRequest,ListGlossariesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

translateDocument(TranslateDocumentRequest request)

public final TranslateDocumentResponse translateDocument(TranslateDocumentRequest request)

Translates documents in synchronous mode.

Sample code:


 // 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()) {
   TranslateDocumentRequest request =
       TranslateDocumentRequest.newBuilder()
           .setParent("parent-995424086")
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .setTargetLanguageCode("targetLanguageCode-106414698")
           .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
           .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
           .setModel("model104069929")
           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
           .putAllLabels(new HashMap<String, String>())
           .setCustomizedAttribution("customizedAttribution557650238")
           .setIsTranslateNativePdfOnly(true)
           .setEnableShadowRemovalNativePdf(true)
           .setEnableRotationCorrection(true)
           .build();
   TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
 }
 
Parameter
NameDescription
requestTranslateDocumentRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslateDocumentResponse

translateDocumentCallable()

public final UnaryCallable<TranslateDocumentRequest,TranslateDocumentResponse> translateDocumentCallable()

Translates documents in synchronous mode.

Sample code:


 // 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()) {
   TranslateDocumentRequest request =
       TranslateDocumentRequest.newBuilder()
           .setParent("parent-995424086")
           .setSourceLanguageCode("sourceLanguageCode1645917472")
           .setTargetLanguageCode("targetLanguageCode-106414698")
           .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
           .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
           .setModel("model104069929")
           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
           .putAllLabels(new HashMap<String, String>())
           .setCustomizedAttribution("customizedAttribution557650238")
           .setIsTranslateNativePdfOnly(true)
           .setEnableShadowRemovalNativePdf(true)
           .setEnableRotationCorrection(true)
           .build();
   ApiFuture<TranslateDocumentResponse> future =
       translationServiceClient.translateDocumentCallable().futureCall(request);
   // Do something.
   TranslateDocumentResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<TranslateDocumentRequest,TranslateDocumentResponse>

translateText(LocationName parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

public final TranslateTextResponse translateText(LocationName parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

Translates input text and returns translated text.

Sample code:


 // 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 model = "model104069929";
   String mimeType = "mimeType-1392120434";
   String sourceLanguageCode = "sourceLanguageCode1645917472";
   String targetLanguageCode = "targetLanguageCode-106414698";
   List<String> contents = new ArrayList<>();
   TranslateTextResponse response =
       translationServiceClient.translateText(
           parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);
 }
 
Parameters
NameDescription
parentLocationName

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for requests using AutoML models or custom glossaries.

Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. The model type requested for this translation.

The format depends on model type:

- AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

- General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

For global (non-regionalized) requests, use location-id global. For example, projects/{project-number-or-id}/locations/global/models/general/nmt.

If not provided, the default Google model (NMT) will be used

mimeTypeString

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

sourceLanguageCodeString

Optional. The ISO-639 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response.

targetLanguageCodeString

Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.

contentsList<String>

Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.

Returns
TypeDescription
TranslateTextResponse

translateText(LocationName parent, String targetLanguageCode, List<String> contents)

public final TranslateTextResponse translateText(LocationName parent, String targetLanguageCode, List<String> contents)

Translates input text and returns translated text.

Sample code:


 // 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);
 }
 
Parameters
NameDescription
parentLocationName

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for requests using AutoML models or custom glossaries.

Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

targetLanguageCodeString

Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.

contentsList<String>

Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.

Returns
TypeDescription
TranslateTextResponse

translateText(TranslateTextRequest request)

public final TranslateTextResponse translateText(TranslateTextRequest request)

Translates input text and returns translated text.

Sample code:


 // 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);
 }
 
Parameter
NameDescription
requestTranslateTextRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TranslateTextResponse

translateText(String parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

public final TranslateTextResponse translateText(String parent, String model, String mimeType, String sourceLanguageCode, String targetLanguageCode, List<String> contents)

Translates input text and returns translated text.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String model = "model104069929";
   String mimeType = "mimeType-1392120434";
   String sourceLanguageCode = "sourceLanguageCode1645917472";
   String targetLanguageCode = "targetLanguageCode-106414698";
   List<String> contents = new ArrayList<>();
   TranslateTextResponse response =
       translationServiceClient.translateText(
           parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);
 }
 
Parameters
NameDescription
parentString

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for requests using AutoML models or custom glossaries.

Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

modelString

Optional. The model type requested for this translation.

The format depends on model type:

- AutoML Translation models: projects/{project-number-or-id}/locations/{location-id}/models/{model-id}

- General (built-in) models: projects/{project-number-or-id}/locations/{location-id}/models/general/nmt,

For global (non-regionalized) requests, use location-id global. For example, projects/{project-number-or-id}/locations/global/models/general/nmt.

If not provided, the default Google model (NMT) will be used

mimeTypeString

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".

sourceLanguageCodeString

Optional. The ISO-639 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response.

targetLanguageCodeString

Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.

contentsList<String>

Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.

Returns
TypeDescription
TranslateTextResponse

translateText(String parent, String targetLanguageCode, List<String> contents)

public final TranslateTextResponse translateText(String parent, String targetLanguageCode, List<String> contents)

Translates input text and returns translated text.

Sample code:


 // 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()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String targetLanguageCode = "targetLanguageCode-106414698";
   List<String> contents = new ArrayList<>();
   TranslateTextResponse response =
       translationServiceClient.translateText(parent, targetLanguageCode, contents);
 }
 
Parameters
NameDescription
parentString

Required. Project or location to make a call. Must refer to a caller's project.

Format: projects/{project-number-or-id} or projects/{project-number-or-id}/locations/{location-id}.

For global calls, use projects/{project-number-or-id}/locations/global or projects/{project-number-or-id}.

Non-global location is required for requests using AutoML models or custom glossaries.

Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

targetLanguageCodeString

Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.

contentsList<String>

Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.

Returns
TypeDescription
TranslateTextResponse

translateTextCallable()

public final UnaryCallable<TranslateTextRequest,TranslateTextResponse> translateTextCallable()

Translates input text and returns translated text.

Sample code:


 // 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();
   ApiFuture<TranslateTextResponse> future =
       translationServiceClient.translateTextCallable().futureCall(request);
   // Do something.
   TranslateTextResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<TranslateTextRequest,TranslateTextResponse>