Google Cloud Translation v3 API - Class TranslationServiceClient (3.3.0)

public abstract class TranslationServiceClient

Reference documentation and code samples for the Google Cloud Translation v3 API class TranslationServiceClient.

TranslationService client wrapper, for convenient use.

Inheritance

object > TranslationServiceClient

Namespace

Google.Cloud.Translate.V3

Assembly

Google.Cloud.Translate.V3.dll

Remarks

Provides natural language translation operations.

Properties

BatchTranslateDocumentOperationsClient

public virtual OperationsClient BatchTranslateDocumentOperationsClient { get; }

The long-running operations client for BatchTranslateDocument.

Property Value
TypeDescription
OperationsClient

BatchTranslateTextOperationsClient

public virtual OperationsClient BatchTranslateTextOperationsClient { get; }

The long-running operations client for BatchTranslateText.

Property Value
TypeDescription
OperationsClient

CreateGlossaryOperationsClient

public virtual OperationsClient CreateGlossaryOperationsClient { get; }

The long-running operations client for CreateGlossary.

Property Value
TypeDescription
OperationsClient

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the TranslationService service, which is a host of "translate.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default TranslationService scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

DeleteGlossaryOperationsClient

public virtual OperationsClient DeleteGlossaryOperationsClient { get; }

The long-running operations client for DeleteGlossary.

Property Value
TypeDescription
OperationsClient

GrpcClient

public virtual TranslationService.TranslationServiceClient GrpcClient { get; }

The underlying gRPC TranslationService client

Property Value
TypeDescription
TranslationServiceTranslationServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

BatchTranslateDocument(LocationName, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CallSettings)

public virtual Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> BatchTranslateDocument(LocationName parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CallSettings callSettings = null)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = translationServiceClient.BatchTranslateDocument(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = translationServiceClient.PollOnceBatchTranslateDocument(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocument(BatchTranslateDocumentRequest, CallSettings)

public virtual Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> BatchTranslateDocument(BatchTranslateDocumentRequest request, CallSettings callSettings = null)

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.

Parameters
NameDescription
requestBatchTranslateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
BatchTranslateDocumentRequest request = new BatchTranslateDocumentRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    InputConfigs =
    {
        new BatchDocumentInputConfig(),
    },
    OutputConfig = new BatchDocumentOutputConfig(),
    Models = { { "", "" }, },
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    FormatConversions = { { "", "" }, },
    CustomizedAttribution = "",
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = translationServiceClient.BatchTranslateDocument(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = translationServiceClient.PollOnceBatchTranslateDocument(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocument(string, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CallSettings)

public virtual Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> BatchTranslateDocument(string parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CallSettings callSettings = null)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = translationServiceClient.BatchTranslateDocument(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = translationServiceClient.PollOnceBatchTranslateDocument(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(LocationName, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CallSettings)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(LocationName parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CallSettings callSettings = null)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(LocationName, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CancellationToken)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(LocationName parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CancellationToken cancellationToken)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(BatchTranslateDocumentRequest, CallSettings)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(BatchTranslateDocumentRequest request, CallSettings callSettings = null)

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.

Parameters
NameDescription
requestBatchTranslateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
BatchTranslateDocumentRequest request = new BatchTranslateDocumentRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    InputConfigs =
    {
        new BatchDocumentInputConfig(),
    },
    OutputConfig = new BatchDocumentOutputConfig(),
    Models = { { "", "" }, },
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    FormatConversions = { { "", "" }, },
    CustomizedAttribution = "",
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(BatchTranslateDocumentRequest, CancellationToken)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(BatchTranslateDocumentRequest request, CancellationToken cancellationToken)

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.

Parameters
NameDescription
requestBatchTranslateDocumentRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
BatchTranslateDocumentRequest request = new BatchTranslateDocumentRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    InputConfigs =
    {
        new BatchDocumentInputConfig(),
    },
    OutputConfig = new BatchDocumentOutputConfig(),
    Models = { { "", "" }, },
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    FormatConversions = { { "", "" }, },
    CustomizedAttribution = "",
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(string, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CallSettings)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(string parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CallSettings callSettings = null)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateDocumentAsync(string, string, IEnumerable<string>, IEnumerable<BatchDocumentInputConfig>, BatchDocumentOutputConfig, CancellationToken)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> BatchTranslateDocumentAsync(string parent, string sourceLanguageCode, IEnumerable<string> targetLanguageCodes, IEnumerable<BatchDocumentInputConfig> inputConfigs, BatchDocumentOutputConfig outputConfig, CancellationToken cancellationToken)

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.

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.

targetLanguageCodesIEnumerablestring

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

inputConfigsIEnumerableBatchDocumentInputConfig

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string sourceLanguageCode = "";
IEnumerable<string> targetLanguageCodes = new string[] { "", };
IEnumerable<BatchDocumentInputConfig> inputConfigs = new BatchDocumentInputConfig[]
{
    new BatchDocumentInputConfig(),
};
BatchDocumentOutputConfig outputConfig = new BatchDocumentOutputConfig();
// Make the request
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> response = await translationServiceClient.BatchTranslateDocumentAsync(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateDocumentResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateDocumentAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateDocumentResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateText(BatchTranslateTextRequest, CallSettings)

public virtual Operation<BatchTranslateResponse, BatchTranslateMetadata> BatchTranslateText(BatchTranslateTextRequest request, CallSettings callSettings = null)

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.

Parameters
NameDescription
requestBatchTranslateTextRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateResponseBatchTranslateMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
BatchTranslateTextRequest request = new BatchTranslateTextRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    Models = { { "", "" }, },
    InputConfigs = { new InputConfig(), },
    OutputConfig = new OutputConfig(),
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    Labels = { { "", "" }, },
};
// Make the request
Operation<BatchTranslateResponse, BatchTranslateMetadata> response = translationServiceClient.BatchTranslateText(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateResponse, BatchTranslateMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchTranslateResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateResponse, BatchTranslateMetadata> retrievedResponse = translationServiceClient.PollOnceBatchTranslateText(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateTextAsync(BatchTranslateTextRequest, CallSettings)

public virtual Task<Operation<BatchTranslateResponse, BatchTranslateMetadata>> BatchTranslateTextAsync(BatchTranslateTextRequest request, CallSettings callSettings = null)

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.

Parameters
NameDescription
requestBatchTranslateTextRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateResponseBatchTranslateMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
BatchTranslateTextRequest request = new BatchTranslateTextRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    Models = { { "", "" }, },
    InputConfigs = { new InputConfig(), },
    OutputConfig = new OutputConfig(),
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    Labels = { { "", "" }, },
};
// Make the request
Operation<BatchTranslateResponse, BatchTranslateMetadata> response = await translationServiceClient.BatchTranslateTextAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateResponse, BatchTranslateMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateResponse, BatchTranslateMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateTextAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateResponse retrievedResult = retrievedResponse.Result;
}

BatchTranslateTextAsync(BatchTranslateTextRequest, CancellationToken)

public virtual Task<Operation<BatchTranslateResponse, BatchTranslateMetadata>> BatchTranslateTextAsync(BatchTranslateTextRequest request, CancellationToken cancellationToken)

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.

Parameters
NameDescription
requestBatchTranslateTextRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationBatchTranslateResponseBatchTranslateMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
BatchTranslateTextRequest request = new BatchTranslateTextRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    SourceLanguageCode = "",
    TargetLanguageCodes = { "", },
    Models = { { "", "" }, },
    InputConfigs = { new InputConfig(), },
    OutputConfig = new OutputConfig(),
    Glossaries =
    {
        {
            "",
            new TranslateTextGlossaryConfig()
        },
    },
    Labels = { { "", "" }, },
};
// Make the request
Operation<BatchTranslateResponse, BatchTranslateMetadata> response = await translationServiceClient.BatchTranslateTextAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchTranslateResponse, BatchTranslateMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchTranslateResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<BatchTranslateResponse, BatchTranslateMetadata> retrievedResponse = await translationServiceClient.PollOnceBatchTranslateTextAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchTranslateResponse retrievedResult = retrievedResponse.Result;
}

Create()

public static TranslationServiceClient Create()

Synchronously creates a TranslationServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TranslationServiceClientBuilder .

Returns
TypeDescription
TranslationServiceClient

The created TranslationServiceClient.

CreateAsync(CancellationToken)

public static Task<TranslationServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a TranslationServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TranslationServiceClientBuilder .

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskTranslationServiceClient

The task representing the created TranslationServiceClient.

CreateGlossary(LocationName, Glossary, CallSettings)

public virtual Operation<Glossary, CreateGlossaryMetadata> CreateGlossary(LocationName parent, Glossary glossary, CallSettings callSettings = null)

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

Parameters
NameDescription
parentLocationName

Required. The project name.

glossaryGlossary

Required. The glossary to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationGlossaryCreateGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = translationServiceClient.CreateGlossary(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceCreateGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossary(CreateGlossaryRequest, CallSettings)

public virtual Operation<Glossary, CreateGlossaryMetadata> CreateGlossary(CreateGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestCreateGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationGlossaryCreateGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
CreateGlossaryRequest request = new CreateGlossaryRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Glossary = new Glossary(),
};
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = translationServiceClient.CreateGlossary(request);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceCreateGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossary(string, Glossary, CallSettings)

public virtual Operation<Glossary, CreateGlossaryMetadata> CreateGlossary(string parent, Glossary glossary, CallSettings callSettings = null)

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

Parameters
NameDescription
parentstring

Required. The project name.

glossaryGlossary

Required. The glossary to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationGlossaryCreateGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = translationServiceClient.CreateGlossary(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceCreateGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(LocationName, Glossary, CallSettings)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(LocationName parent, Glossary glossary, CallSettings callSettings = null)

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

Parameters
NameDescription
parentLocationName

Required. The project name.

glossaryGlossary

Required. The glossary to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(LocationName, Glossary, CancellationToken)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(LocationName parent, Glossary glossary, CancellationToken cancellationToken)

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

Parameters
NameDescription
parentLocationName

Required. The project name.

glossaryGlossary

Required. The glossary to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(CreateGlossaryRequest, CallSettings)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(CreateGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestCreateGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
CreateGlossaryRequest request = new CreateGlossaryRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Glossary = new Glossary(),
};
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(request);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(CreateGlossaryRequest, CancellationToken)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(CreateGlossaryRequest request, CancellationToken cancellationToken)

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

Parameters
NameDescription
requestCreateGlossaryRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
CreateGlossaryRequest request = new CreateGlossaryRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Glossary = new Glossary(),
};
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(request);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(string, Glossary, CallSettings)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(string parent, Glossary glossary, CallSettings callSettings = null)

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

Parameters
NameDescription
parentstring

Required. The project name.

glossaryGlossary

Required. The glossary to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

CreateGlossaryAsync(string, Glossary, CancellationToken)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> CreateGlossaryAsync(string parent, Glossary glossary, CancellationToken cancellationToken)

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

Parameters
NameDescription
parentstring

Required. The project name.

glossaryGlossary

Required. The glossary to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
Glossary glossary = new Glossary();
// Make the request
Operation<Glossary, CreateGlossaryMetadata> response = await translationServiceClient.CreateGlossaryAsync(parent, glossary);

// Poll until the returned long-running operation is complete
Operation<Glossary, CreateGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Glossary result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Glossary, CreateGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceCreateGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Glossary retrievedResult = retrievedResponse.Result;
}

DeleteGlossary(DeleteGlossaryRequest, CallSettings)

public virtual Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> DeleteGlossary(DeleteGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestDeleteGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDeleteGlossaryResponseDeleteGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
DeleteGlossaryRequest request = new DeleteGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = translationServiceClient.DeleteGlossary(request);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceDeleteGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossary(GlossaryName, CallSettings)

public virtual Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> DeleteGlossary(GlossaryName name, CallSettings callSettings = null)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDeleteGlossaryResponseDeleteGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = translationServiceClient.DeleteGlossary(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceDeleteGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossary(string, CallSettings)

public virtual Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> DeleteGlossary(string name, CallSettings callSettings = null)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDeleteGlossaryResponseDeleteGlossaryMetadata

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = translationServiceClient.DeleteGlossary(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = translationServiceClient.PollOnceDeleteGlossary(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(DeleteGlossaryRequest, CallSettings)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(DeleteGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestDeleteGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
DeleteGlossaryRequest request = new DeleteGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(request);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(DeleteGlossaryRequest, CancellationToken)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(DeleteGlossaryRequest request, CancellationToken cancellationToken)

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

Parameters
NameDescription
requestDeleteGlossaryRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
DeleteGlossaryRequest request = new DeleteGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(request);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(GlossaryName, CallSettings)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(GlossaryName name, CallSettings callSettings = null)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(GlossaryName, CancellationToken)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(GlossaryName name, CancellationToken cancellationToken)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to delete.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(string, CallSettings)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(string name, CallSettings callSettings = null)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to delete.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DeleteGlossaryAsync(string, CancellationToken)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> DeleteGlossaryAsync(string name, CancellationToken cancellationToken)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to delete.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> response = await translationServiceClient.DeleteGlossaryAsync(name);

// Poll until the returned long-running operation is complete
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeleteGlossaryResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> retrievedResponse = await translationServiceClient.PollOnceDeleteGlossaryAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DeleteGlossaryResponse retrievedResult = retrievedResponse.Result;
}

DetectLanguage(LocationName, string, string, string, CallSettings)

public virtual DetectLanguageResponse DetectLanguage(LocationName parent, string model, string mimeType, string content, CallSettings callSettings = null)

Detects the language of text within a request.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
DetectLanguageResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = translationServiceClient.DetectLanguage(parent, model, mimeType, content);

DetectLanguage(DetectLanguageRequest, CallSettings)

public virtual DetectLanguageResponse DetectLanguage(DetectLanguageRequest request, CallSettings callSettings = null)

Detects the language of text within a request.

Parameters
NameDescription
requestDetectLanguageRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
DetectLanguageResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
DetectLanguageRequest request = new DetectLanguageRequest
{
    Content = "",
    MimeType = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
DetectLanguageResponse response = translationServiceClient.DetectLanguage(request);

DetectLanguage(string, string, string, string, CallSettings)

public virtual DetectLanguageResponse DetectLanguage(string parent, string model, string mimeType, string content, CallSettings callSettings = null)

Detects the language of text within a request.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
DetectLanguageResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = translationServiceClient.DetectLanguage(parent, model, mimeType, content);

DetectLanguageAsync(LocationName, string, string, string, CallSettings)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(LocationName parent, string model, string mimeType, string content, CallSettings callSettings = null)

Detects the language of text within a request.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(parent, model, mimeType, content);

DetectLanguageAsync(LocationName, string, string, string, CancellationToken)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(LocationName parent, string model, string mimeType, string content, CancellationToken cancellationToken)

Detects the language of text within a request.

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(parent, model, mimeType, content);

DetectLanguageAsync(DetectLanguageRequest, CallSettings)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(DetectLanguageRequest request, CallSettings callSettings = null)

Detects the language of text within a request.

Parameters
NameDescription
requestDetectLanguageRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
DetectLanguageRequest request = new DetectLanguageRequest
{
    Content = "",
    MimeType = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(request);

DetectLanguageAsync(DetectLanguageRequest, CancellationToken)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(DetectLanguageRequest request, CancellationToken cancellationToken)

Detects the language of text within a request.

Parameters
NameDescription
requestDetectLanguageRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
DetectLanguageRequest request = new DetectLanguageRequest
{
    Content = "",
    MimeType = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(request);

DetectLanguageAsync(string, string, string, string, CallSettings)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(string parent, string model, string mimeType, string content, CallSettings callSettings = null)

Detects the language of text within a request.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(parent, model, mimeType, content);

DetectLanguageAsync(string, string, string, string, CancellationToken)

public virtual Task<DetectLanguageResponse> DetectLanguageAsync(string parent, string model, string mimeType, string content, CancellationToken cancellationToken)

Detects the language of text within a request.

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskDetectLanguageResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string content = "";
// Make the request
DetectLanguageResponse response = await translationServiceClient.DetectLanguageAsync(parent, model, mimeType, content);

GetGlossary(GetGlossaryRequest, CallSettings)

public virtual Glossary GetGlossary(GetGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestGetGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Glossary

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
GetGlossaryRequest request = new GetGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Glossary response = translationServiceClient.GetGlossary(request);

GetGlossary(GlossaryName, CallSettings)

public virtual Glossary GetGlossary(GlossaryName name, CallSettings callSettings = null)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Glossary

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Glossary response = translationServiceClient.GetGlossary(name);

GetGlossary(string, CallSettings)

public virtual Glossary GetGlossary(string name, CallSettings callSettings = null)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Glossary

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Glossary response = translationServiceClient.GetGlossary(name);

GetGlossaryAsync(GetGlossaryRequest, CallSettings)

public virtual Task<Glossary> GetGlossaryAsync(GetGlossaryRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestGetGlossaryRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GetGlossaryRequest request = new GetGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(request);

GetGlossaryAsync(GetGlossaryRequest, CancellationToken)

public virtual Task<Glossary> GetGlossaryAsync(GetGlossaryRequest request, CancellationToken cancellationToken)

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

Parameters
NameDescription
requestGetGlossaryRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GetGlossaryRequest request = new GetGlossaryRequest
{
    GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
};
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(request);

GetGlossaryAsync(GlossaryName, CallSettings)

public virtual Task<Glossary> GetGlossaryAsync(GlossaryName name, CallSettings callSettings = null)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(name);

GetGlossaryAsync(GlossaryName, CancellationToken)

public virtual Task<Glossary> GetGlossaryAsync(GlossaryName name, CancellationToken cancellationToken)

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

Parameters
NameDescription
nameGlossaryName

Required. The name of the glossary to retrieve.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GlossaryName name = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(name);

GetGlossaryAsync(string, CallSettings)

public virtual Task<Glossary> GetGlossaryAsync(string name, CallSettings callSettings = null)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to retrieve.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(name);

GetGlossaryAsync(string, CancellationToken)

public virtual Task<Glossary> GetGlossaryAsync(string name, CancellationToken cancellationToken)

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

Parameters
NameDescription
namestring

Required. The name of the glossary to retrieve.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskGlossary

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/glossaries/[GLOSSARY]";
// Make the request
Glossary response = await translationServiceClient.GetGlossaryAsync(name);

GetSupportedLanguages(LocationName, string, string, CallSettings)

public virtual SupportedLanguages GetSupportedLanguages(LocationName parent, string model, string displayLanguageCode, CallSettings callSettings = null)

Returns a list of supported languages for translation.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SupportedLanguages

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = translationServiceClient.GetSupportedLanguages(parent, model, displayLanguageCode);

GetSupportedLanguages(GetSupportedLanguagesRequest, CallSettings)

public virtual SupportedLanguages GetSupportedLanguages(GetSupportedLanguagesRequest request, CallSettings callSettings = null)

Returns a list of supported languages for translation.

Parameters
NameDescription
requestGetSupportedLanguagesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SupportedLanguages

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
GetSupportedLanguagesRequest request = new GetSupportedLanguagesRequest
{
    DisplayLanguageCode = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
};
// Make the request
SupportedLanguages response = translationServiceClient.GetSupportedLanguages(request);

GetSupportedLanguages(string, string, string, CallSettings)

public virtual SupportedLanguages GetSupportedLanguages(string parent, string model, string displayLanguageCode, CallSettings callSettings = null)

Returns a list of supported languages for translation.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
SupportedLanguages

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = translationServiceClient.GetSupportedLanguages(parent, model, displayLanguageCode);

GetSupportedLanguagesAsync(LocationName, string, string, CallSettings)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(LocationName parent, string model, string displayLanguageCode, CallSettings callSettings = null)

Returns a list of supported languages for translation.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(parent, model, displayLanguageCode);

GetSupportedLanguagesAsync(LocationName, string, string, CancellationToken)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(LocationName parent, string model, string displayLanguageCode, CancellationToken cancellationToken)

Returns a list of supported languages for translation.

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(parent, model, displayLanguageCode);

GetSupportedLanguagesAsync(GetSupportedLanguagesRequest, CallSettings)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(GetSupportedLanguagesRequest request, CallSettings callSettings = null)

Returns a list of supported languages for translation.

Parameters
NameDescription
requestGetSupportedLanguagesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GetSupportedLanguagesRequest request = new GetSupportedLanguagesRequest
{
    DisplayLanguageCode = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
};
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(request);

GetSupportedLanguagesAsync(GetSupportedLanguagesRequest, CancellationToken)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(GetSupportedLanguagesRequest request, CancellationToken cancellationToken)

Returns a list of supported languages for translation.

Parameters
NameDescription
requestGetSupportedLanguagesRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
GetSupportedLanguagesRequest request = new GetSupportedLanguagesRequest
{
    DisplayLanguageCode = "",
    Model = "",
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
};
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(request);

GetSupportedLanguagesAsync(string, string, string, CallSettings)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(string parent, string model, string displayLanguageCode, CallSettings callSettings = null)

Returns a list of supported languages for translation.

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(parent, model, displayLanguageCode);

GetSupportedLanguagesAsync(string, string, string, CancellationToken)

public virtual Task<SupportedLanguages> GetSupportedLanguagesAsync(string parent, string model, string displayLanguageCode, CancellationToken cancellationToken)

Returns a list of supported languages for translation.

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskSupportedLanguages

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string displayLanguageCode = "";
// Make the request
SupportedLanguages response = await translationServiceClient.GetSupportedLanguagesAsync(parent, model, displayLanguageCode);

ListGlossaries(LocationName, string, int?, CallSettings)

public virtual PagedEnumerable<ListGlossariesResponse, Glossary> ListGlossaries(LocationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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

Parameters
NameDescription
parentLocationName

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

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListGlossariesResponseGlossary

A pageable sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
// Make the request
PagedEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossaries(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Glossary item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListGlossariesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListGlossaries(ListGlossariesRequest, CallSettings)

public virtual PagedEnumerable<ListGlossariesResponse, Glossary> ListGlossaries(ListGlossariesRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestListGlossariesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListGlossariesResponseGlossary

A pageable sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
ListGlossariesRequest request = new ListGlossariesRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Filter = "",
};
// Make the request
PagedEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossaries(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Glossary item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListGlossariesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListGlossaries(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListGlossariesResponse, Glossary> ListGlossaries(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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

Parameters
NameDescription
parentstring

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

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListGlossariesResponseGlossary

A pageable sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
// Make the request
PagedEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossaries(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Glossary item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListGlossariesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListGlossariesAsync(LocationName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListGlossariesResponse, Glossary> ListGlossariesAsync(LocationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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

Parameters
NameDescription
parentLocationName

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

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListGlossariesResponseGlossary

A pageable asynchronous sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
// Make the request
PagedAsyncEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossariesAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Glossary item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListGlossariesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListGlossariesAsync(ListGlossariesRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListGlossariesResponse, Glossary> ListGlossariesAsync(ListGlossariesRequest request, CallSettings callSettings = null)

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

Parameters
NameDescription
requestListGlossariesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListGlossariesResponseGlossary

A pageable asynchronous sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
ListGlossariesRequest request = new ListGlossariesRequest
{
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Filter = "",
};
// Make the request
PagedAsyncEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossariesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Glossary item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListGlossariesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListGlossariesAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListGlossariesResponse, Glossary> ListGlossariesAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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

Parameters
NameDescription
parentstring

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

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListGlossariesResponseGlossary

A pageable asynchronous sequence of Glossary resources.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
// Make the request
PagedAsyncEnumerable<ListGlossariesResponse, Glossary> response = translationServiceClient.ListGlossariesAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Glossary item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListGlossariesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Glossary item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Glossary> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Glossary item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

PollOnceBatchTranslateDocument(string, CallSettings)

public virtual Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> PollOnceBatchTranslateDocument(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of BatchTranslateDocument.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

The result of polling the operation.

PollOnceBatchTranslateDocumentAsync(string, CallSettings)

public virtual Task<Operation<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>> PollOnceBatchTranslateDocumentAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of BatchTranslateDocument.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateDocumentResponseBatchTranslateDocumentMetadata

A task representing the result of polling the operation.

PollOnceBatchTranslateText(string, CallSettings)

public virtual Operation<BatchTranslateResponse, BatchTranslateMetadata> PollOnceBatchTranslateText(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of BatchTranslateText .

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchTranslateResponseBatchTranslateMetadata

The result of polling the operation.

PollOnceBatchTranslateTextAsync(string, CallSettings)

public virtual Task<Operation<BatchTranslateResponse, BatchTranslateMetadata>> PollOnceBatchTranslateTextAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of BatchTranslateText.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchTranslateResponseBatchTranslateMetadata

A task representing the result of polling the operation.

PollOnceCreateGlossary(string, CallSettings)

public virtual Operation<Glossary, CreateGlossaryMetadata> PollOnceCreateGlossary(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of CreateGlossary.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationGlossaryCreateGlossaryMetadata

The result of polling the operation.

PollOnceCreateGlossaryAsync(string, CallSettings)

public virtual Task<Operation<Glossary, CreateGlossaryMetadata>> PollOnceCreateGlossaryAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of CreateGlossary.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationGlossaryCreateGlossaryMetadata

A task representing the result of polling the operation.

PollOnceDeleteGlossary(string, CallSettings)

public virtual Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata> PollOnceDeleteGlossary(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of DeleteGlossary.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDeleteGlossaryResponseDeleteGlossaryMetadata

The result of polling the operation.

PollOnceDeleteGlossaryAsync(string, CallSettings)

public virtual Task<Operation<DeleteGlossaryResponse, DeleteGlossaryMetadata>> PollOnceDeleteGlossaryAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of DeleteGlossary.

Parameters
NameDescription
operationNamestring

The name of a previously invoked operation. Must not be null or empty.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDeleteGlossaryResponseDeleteGlossaryMetadata

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

TranslateDocument(TranslateDocumentRequest, CallSettings)

public virtual TranslateDocumentResponse TranslateDocument(TranslateDocumentRequest request, CallSettings callSettings = null)

Translates documents in synchronous mode.

Parameters
NameDescription
requestTranslateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateDocumentResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
TranslateDocumentRequest request = new TranslateDocumentRequest
{
    Parent = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    DocumentInputConfig = new DocumentInputConfig(),
    DocumentOutputConfig = new DocumentOutputConfig(),
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    Labels = { { "", "" }, },
    CustomizedAttribution = "",
    IsTranslateNativePdfOnly = false,
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
TranslateDocumentResponse response = translationServiceClient.TranslateDocument(request);

TranslateDocumentAsync(TranslateDocumentRequest, CallSettings)

public virtual Task<TranslateDocumentResponse> TranslateDocumentAsync(TranslateDocumentRequest request, CallSettings callSettings = null)

Translates documents in synchronous mode.

Parameters
NameDescription
requestTranslateDocumentRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateDocumentResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
TranslateDocumentRequest request = new TranslateDocumentRequest
{
    Parent = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    DocumentInputConfig = new DocumentInputConfig(),
    DocumentOutputConfig = new DocumentOutputConfig(),
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    Labels = { { "", "" }, },
    CustomizedAttribution = "",
    IsTranslateNativePdfOnly = false,
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
TranslateDocumentResponse response = await translationServiceClient.TranslateDocumentAsync(request);

TranslateDocumentAsync(TranslateDocumentRequest, CancellationToken)

public virtual Task<TranslateDocumentResponse> TranslateDocumentAsync(TranslateDocumentRequest request, CancellationToken cancellationToken)

Translates documents in synchronous mode.

Parameters
NameDescription
requestTranslateDocumentRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateDocumentResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
TranslateDocumentRequest request = new TranslateDocumentRequest
{
    Parent = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    DocumentInputConfig = new DocumentInputConfig(),
    DocumentOutputConfig = new DocumentOutputConfig(),
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    Labels = { { "", "" }, },
    CustomizedAttribution = "",
    IsTranslateNativePdfOnly = false,
    EnableShadowRemovalNativePdf = false,
    EnableRotationCorrection = false,
};
// Make the request
TranslateDocumentResponse response = await translationServiceClient.TranslateDocumentAsync(request);

TranslateText(LocationName, string, IEnumerable<string>, CallSettings)

public virtual TranslateTextResponse TranslateText(LocationName parent, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateTextResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = translationServiceClient.TranslateText(parent, targetLanguageCode, contents);

TranslateText(LocationName, string, string, string, string, IEnumerable<string>, CallSettings)

public virtual TranslateTextResponse TranslateText(LocationName parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateTextResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = translationServiceClient.TranslateText(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);

TranslateText(TranslateTextRequest, CallSettings)

public virtual TranslateTextResponse TranslateText(TranslateTextRequest request, CallSettings callSettings = null)

Translates input text and returns translated text.

Parameters
NameDescription
requestTranslateTextRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateTextResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
TranslateTextRequest request = new TranslateTextRequest
{
    Contents = { "", },
    MimeType = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
TranslateTextResponse response = translationServiceClient.TranslateText(request);

TranslateText(string, string, IEnumerable<string>, CallSettings)

public virtual TranslateTextResponse TranslateText(string parent, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateTextResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = translationServiceClient.TranslateText(parent, targetLanguageCode, contents);

TranslateText(string, string, string, string, string, IEnumerable<string>, CallSettings)

public virtual TranslateTextResponse TranslateText(string parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TranslateTextResponse

The RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = translationServiceClient.TranslateText(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);

TranslateTextAsync(LocationName, string, IEnumerable<string>, CallSettings)

public virtual Task<TranslateTextResponse> TranslateTextAsync(LocationName parent, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, targetLanguageCode, contents);

TranslateTextAsync(LocationName, string, IEnumerable<string>, CancellationToken)

public virtual Task<TranslateTextResponse> TranslateTextAsync(LocationName parent, string targetLanguageCode, IEnumerable<string> contents, CancellationToken cancellationToken)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, targetLanguageCode, contents);

TranslateTextAsync(LocationName, string, string, string, string, IEnumerable<string>, CallSettings)

public virtual Task<TranslateTextResponse> TranslateTextAsync(LocationName parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);

TranslateTextAsync(LocationName, string, string, string, string, IEnumerable<string>, CancellationToken)

public virtual Task<TranslateTextResponse> TranslateTextAsync(LocationName parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CancellationToken cancellationToken)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);

TranslateTextAsync(TranslateTextRequest, CallSettings)

public virtual Task<TranslateTextResponse> TranslateTextAsync(TranslateTextRequest request, CallSettings callSettings = null)

Translates input text and returns translated text.

Parameters
NameDescription
requestTranslateTextRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
TranslateTextRequest request = new TranslateTextRequest
{
    Contents = { "", },
    MimeType = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(request);

TranslateTextAsync(TranslateTextRequest, CancellationToken)

public virtual Task<TranslateTextResponse> TranslateTextAsync(TranslateTextRequest request, CancellationToken cancellationToken)

Translates input text and returns translated text.

Parameters
NameDescription
requestTranslateTextRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
TranslateTextRequest request = new TranslateTextRequest
{
    Contents = { "", },
    MimeType = "",
    SourceLanguageCode = "",
    TargetLanguageCode = "",
    Model = "",
    GlossaryConfig = new TranslateTextGlossaryConfig(),
    ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
    Labels = { { "", "" }, },
};
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(request);

TranslateTextAsync(string, string, IEnumerable<string>, CallSettings)

public virtual Task<TranslateTextResponse> TranslateTextAsync(string parent, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, targetLanguageCode, contents);

TranslateTextAsync(string, string, IEnumerable<string>, CancellationToken)

public virtual Task<TranslateTextResponse> TranslateTextAsync(string parent, string targetLanguageCode, IEnumerable<string> contents, CancellationToken cancellationToken)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, targetLanguageCode, contents);

TranslateTextAsync(string, string, string, string, string, IEnumerable<string>, CallSettings)

public virtual Task<TranslateTextResponse> TranslateTextAsync(string parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CallSettings callSettings = null)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);

TranslateTextAsync(string, string, string, string, string, IEnumerable<string>, CancellationToken)

public virtual Task<TranslateTextResponse> TranslateTextAsync(string parent, string model, string mimeType, string sourceLanguageCode, string targetLanguageCode, IEnumerable<string> contents, CancellationToken cancellationToken)

Translates input text and returns translated text.

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.

contentsIEnumerablestring

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.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTranslateTextResponse

A Task containing the RPC response.

Example
// Create client
TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
string model = "";
string mimeType = "";
string sourceLanguageCode = "";
string targetLanguageCode = "";
IEnumerable<string> contents = new string[] { "", };
// Make the request
TranslateTextResponse response = await translationServiceClient.TranslateTextAsync(parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);