Cloud Translation V3 API - Class Google::Cloud::Translate::V3::TranslationService::Rest::Client (v0.10.0)

Reference documentation and code samples for the Cloud Translation V3 API class Google::Cloud::Translate::V3::TranslationService::Rest::Client.

REST client for the TranslationService service.

Provides natural language translation operations.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the TranslationService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all TranslationService clients
::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#adaptive_mt_translate

def adaptive_mt_translate(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse
def adaptive_mt_translate(parent: nil, dataset: nil, content: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse

Translate text using Adaptive MT.

Overloads
def adaptive_mt_translate(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse
Pass arguments to adaptive_mt_translate via a request object, either of type AdaptiveMtTranslateRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def adaptive_mt_translate(parent: nil, dataset: nil, content: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse
Pass arguments to adaptive_mt_translate via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. Location to make a regional call.

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

  • dataset (::String) — Required. The resource name for the dataset to use for adaptive MT. projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}
  • content (::Array<::String>) — Required. The content of the input in string format. For now only one sentence per request is supported.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::AdaptiveMtTranslateRequest.new

# Call the adaptive_mt_translate method.
result = client.adaptive_mt_translate request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtTranslateResponse.
p result

#batch_translate_document

def batch_translate_document(request, options = nil) -> ::Gapic::Operation
def batch_translate_document(parent: nil, source_language_code: nil, target_language_codes: nil, input_configs: nil, output_config: nil, models: nil, glossaries: nil, format_conversions: nil, customized_attribution: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) -> ::Gapic::Operation

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.

Overloads
def batch_translate_document(request, options = nil) -> ::Gapic::Operation
Pass arguments to batch_translate_document via a request object, either of type BatchTranslateDocumentRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def batch_translate_document(parent: nil, source_language_code: nil, target_language_codes: nil, input_configs: nil, output_config: nil, models: nil, glossaries: nil, format_conversions: nil, customized_attribution: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) -> ::Gapic::Operation
Pass arguments to batch_translate_document via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — 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.

  • source_language_code (::String) — 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.
  • target_language_codes (::Array<::String>) — Required. The ISO-639 language code to use for translation of the input document. Specify up to 10 language codes here.
  • input_configs (::Array<::Google::Cloud::Translate::V3::BatchDocumentInputConfig, ::Hash>) — 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.
  • output_config (::Google::Cloud::Translate::V3::BatchDocumentOutputConfig, ::Hash) — 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.
  • models (::Hash{::String => ::String}) — Optional. The models to use for translation. Map's key is target language code. Map's value is the model name. Value can be a built-in general model, or an AutoML Translation model.

    The value 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,

    If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.

  • glossaries (::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}) — Optional. Glossaries to be applied. It's keyed by target language code.
  • format_conversions (::Hash{::String => ::String}) — Optional. The file format conversion map that is applied to all input files. The map key is the original mime_type. The map value is the target mime_type of translated documents.

    Supported file format conversion includes:

    • application/pdf to application/vnd.openxmlformats-officedocument.wordprocessingml.document

    If nothing specified, output files will be in the same format as the original file.

  • customized_attribution (::String) — Optional. This flag is to support user customized attribution. If not provided, the default is Machine Translated by Google. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos
  • enable_shadow_removal_native_pdf (::Boolean) — Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false
  • enable_rotation_correction (::Boolean) — Optional. If true, enable auto rotation correction in DVS.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::BatchTranslateDocumentRequest.new

# Call the batch_translate_document method.
result = client.batch_translate_document request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#batch_translate_text

def batch_translate_text(request, options = nil) -> ::Gapic::Operation
def batch_translate_text(parent: nil, source_language_code: nil, target_language_codes: nil, models: nil, input_configs: nil, output_config: nil, glossaries: nil, labels: nil) -> ::Gapic::Operation

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.

Overloads
def batch_translate_text(request, options = nil) -> ::Gapic::Operation
Pass arguments to batch_translate_text via a request object, either of type BatchTranslateTextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::BatchTranslateTextRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def batch_translate_text(parent: nil, source_language_code: nil, target_language_codes: nil, models: nil, input_configs: nil, output_config: nil, glossaries: nil, labels: nil) -> ::Gapic::Operation
Pass arguments to batch_translate_text via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. Location to make a call. Must refer to a caller's project.

    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.

  • source_language_code (::String) — Required. Source language code.
  • target_language_codes (::Array<::String>) — Required. Specify up to 10 language codes here.
  • models (::Hash{::String => ::String}) — Optional. The models to use for translation. Map's key is target language code. Map's value is model name. Value can be a built-in general model, or an AutoML Translation model.

    The value 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,

    If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.

  • input_configs (::Array<::Google::Cloud::Translate::V3::InputConfig, ::Hash>) — Required. Input configurations. The total number of files matched should be <= 100. The total content size should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.
  • output_config (::Google::Cloud::Translate::V3::OutputConfig, ::Hash) — 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.
  • glossaries (::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}) — Optional. Glossaries to be applied for translation. It's keyed by target language code.
  • labels (::Hash{::String => ::String}) — Optional. The labels with user-defined metadata for the request.

    Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

    See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::BatchTranslateTextRequest.new

# Call the batch_translate_text method.
result = client.batch_translate_text request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the TranslationService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_adaptive_mt_dataset

def create_adaptive_mt_dataset(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
def create_adaptive_mt_dataset(parent: nil, adaptive_mt_dataset: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset

Creates an Adaptive MT dataset.

Overloads
def create_adaptive_mt_dataset(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
Pass arguments to create_adaptive_mt_dataset via a request object, either of type CreateAdaptiveMtDatasetRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def create_adaptive_mt_dataset(parent: nil, adaptive_mt_dataset: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
Pass arguments to create_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. Name of the parent project. In form of projects/{project-number-or-id}/locations/{location-id}
  • adaptive_mt_dataset (::Google::Cloud::Translate::V3::AdaptiveMtDataset, ::Hash) — Required. The AdaptiveMtDataset to be created.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateAdaptiveMtDatasetRequest.new

# Call the create_adaptive_mt_dataset method.
result = client.create_adaptive_mt_dataset request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
p result

#create_glossary

def create_glossary(request, options = nil) -> ::Gapic::Operation
def create_glossary(parent: nil, glossary: nil) -> ::Gapic::Operation

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

Overloads
def create_glossary(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_glossary via a request object, either of type CreateGlossaryRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::CreateGlossaryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def create_glossary(parent: nil, glossary: nil) -> ::Gapic::Operation
Pass arguments to create_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::CreateGlossaryRequest.new

# Call the create_glossary method.
result = client.create_glossary request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#delete_adaptive_mt_dataset

def delete_adaptive_mt_dataset(request, options = nil) -> ::Google::Protobuf::Empty
def delete_adaptive_mt_dataset(name: nil) -> ::Google::Protobuf::Empty

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

Overloads
def delete_adaptive_mt_dataset(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_adaptive_mt_dataset via a request object, either of type DeleteAdaptiveMtDatasetRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def delete_adaptive_mt_dataset(name: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteAdaptiveMtDatasetRequest.new

# Call the delete_adaptive_mt_dataset method.
result = client.delete_adaptive_mt_dataset request

# The returned object is of type Google::Protobuf::Empty.
p result

#delete_adaptive_mt_file

def delete_adaptive_mt_file(request, options = nil) -> ::Google::Protobuf::Empty
def delete_adaptive_mt_file(name: nil) -> ::Google::Protobuf::Empty

Deletes an AdaptiveMtFile along with its sentences.

Overloads
def delete_adaptive_mt_file(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_adaptive_mt_file via a request object, either of type DeleteAdaptiveMtFileRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def delete_adaptive_mt_file(name: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_adaptive_mt_file via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the file to delete, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteAdaptiveMtFileRequest.new

# Call the delete_adaptive_mt_file method.
result = client.delete_adaptive_mt_file request

# The returned object is of type Google::Protobuf::Empty.
p result

#delete_glossary

def delete_glossary(request, options = nil) -> ::Gapic::Operation
def delete_glossary(name: nil) -> ::Gapic::Operation

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

Overloads
def delete_glossary(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_glossary via a request object, either of type DeleteGlossaryRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::DeleteGlossaryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def delete_glossary(name: nil) -> ::Gapic::Operation
Pass arguments to delete_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The name of the glossary to delete.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DeleteGlossaryRequest.new

# Call the delete_glossary method.
result = client.delete_glossary request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#detect_language

def detect_language(request, options = nil) -> ::Google::Cloud::Translate::V3::DetectLanguageResponse
def detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil) -> ::Google::Cloud::Translate::V3::DetectLanguageResponse

Detects the language of text within a request.

Overloads
def detect_language(request, options = nil) -> ::Google::Cloud::Translate::V3::DetectLanguageResponse
Pass arguments to detect_language via a request object, either of type DetectLanguageRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::DetectLanguageRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil) -> ::Google::Cloud::Translate::V3::DetectLanguageResponse
Pass arguments to detect_language via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — 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.

  • model (::String) — 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.

  • content (::String) — The content of the input stored as a string.
  • mime_type (::String) — Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".
  • labels (::Hash{::String => ::String}) — Optional. The labels with user-defined metadata for the request.

    Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

    See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::DetectLanguageRequest.new

# Call the detect_language method.
result = client.detect_language request

# The returned object is of type Google::Cloud::Translate::V3::DetectLanguageResponse.
p result

#get_adaptive_mt_dataset

def get_adaptive_mt_dataset(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
def get_adaptive_mt_dataset(name: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset

Gets the Adaptive MT dataset.

Overloads
def get_adaptive_mt_dataset(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
Pass arguments to get_adaptive_mt_dataset via a request object, either of type GetAdaptiveMtDatasetRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_adaptive_mt_dataset(name: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtDataset
Pass arguments to get_adaptive_mt_dataset via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. Name of the dataset. In the form of projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetAdaptiveMtDatasetRequest.new

# Call the get_adaptive_mt_dataset method.
result = client.get_adaptive_mt_dataset request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtDataset.
p result

#get_adaptive_mt_file

def get_adaptive_mt_file(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtFile
def get_adaptive_mt_file(name: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtFile

Gets and AdaptiveMtFile

Overloads
def get_adaptive_mt_file(request, options = nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtFile
Pass arguments to get_adaptive_mt_file via a request object, either of type GetAdaptiveMtFileRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_adaptive_mt_file(name: nil) -> ::Google::Cloud::Translate::V3::AdaptiveMtFile
Pass arguments to get_adaptive_mt_file via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the file, in form of projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetAdaptiveMtFileRequest.new

# Call the get_adaptive_mt_file method.
result = client.get_adaptive_mt_file request

# The returned object is of type Google::Cloud::Translate::V3::AdaptiveMtFile.
p result

#get_glossary

def get_glossary(request, options = nil) -> ::Google::Cloud::Translate::V3::Glossary
def get_glossary(name: nil) -> ::Google::Cloud::Translate::V3::Glossary

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

Overloads
def get_glossary(request, options = nil) -> ::Google::Cloud::Translate::V3::Glossary
Pass arguments to get_glossary via a request object, either of type GetGlossaryRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::GetGlossaryRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_glossary(name: nil) -> ::Google::Cloud::Translate::V3::Glossary
Pass arguments to get_glossary via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The name of the glossary to retrieve.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetGlossaryRequest.new

# Call the get_glossary method.
result = client.get_glossary request

# The returned object is of type Google::Cloud::Translate::V3::Glossary.
p result

#get_supported_languages

def get_supported_languages(request, options = nil) -> ::Google::Cloud::Translate::V3::SupportedLanguages
def get_supported_languages(parent: nil, display_language_code: nil, model: nil) -> ::Google::Cloud::Translate::V3::SupportedLanguages

Returns a list of supported languages for translation.

Overloads
def get_supported_languages(request, options = nil) -> ::Google::Cloud::Translate::V3::SupportedLanguages
Pass arguments to get_supported_languages via a request object, either of type GetSupportedLanguagesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_supported_languages(parent: nil, display_language_code: nil, model: nil) -> ::Google::Cloud::Translate::V3::SupportedLanguages
Pass arguments to get_supported_languages via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — 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.

  • display_language_code (::String) — 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.
  • model (::String) — 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.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::GetSupportedLanguagesRequest.new

# Call the get_supported_languages method.
result = client.get_supported_languages request

# The returned object is of type Google::Cloud::Translate::V3::SupportedLanguages.
p result

#import_adaptive_mt_file

def import_adaptive_mt_file(request, options = nil) -> ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse
def import_adaptive_mt_file(parent: nil, file_input_source: nil, gcs_input_source: nil) -> ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse

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

Overloads
def import_adaptive_mt_file(request, options = nil) -> ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse
Pass arguments to import_adaptive_mt_file via a request object, either of type ImportAdaptiveMtFileRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def import_adaptive_mt_file(parent: nil, file_input_source: nil, gcs_input_source: nil) -> ::Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse
Pass arguments to import_adaptive_mt_file via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ImportAdaptiveMtFileRequest.new

# Call the import_adaptive_mt_file method.
result = client.import_adaptive_mt_file request

# The returned object is of type Google::Cloud::Translate::V3::ImportAdaptiveMtFileResponse.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new TranslationService REST client object.

Yields
  • (config) — Configure the TranslationService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
  config.timeout = 10.0
end

#list_adaptive_mt_datasets

def list_adaptive_mt_datasets(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>
def list_adaptive_mt_datasets(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>

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

Overloads
def list_adaptive_mt_datasets(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>
Pass arguments to list_adaptive_mt_datasets via a request object, either of type ListAdaptiveMtDatasetsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_adaptive_mt_datasets(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtDataset>
Pass arguments to list_adaptive_mt_datasets via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the project from which to list the Adaptive MT datasets. projects/{project-number-or-id}/locations/{location-id}
  • page_size (::Integer) — Optional. Requested page size. The server may return fewer results than requested. If unspecified, the server picks an appropriate default.
  • page_token (::String) — Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtDatasetsResponse.next_page_token returned from the previous call to ListAdaptiveMtDatasets method. The first page is returned if page_tokenis empty or missing.
  • filter (::String) — Optional. An expression for filtering the results of the request. Filter is not supported yet.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtDatasetsRequest.new

# Call the list_adaptive_mt_datasets method.
result = client.list_adaptive_mt_datasets request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtDataset.
  p item
end

#list_adaptive_mt_files

def list_adaptive_mt_files(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>
def list_adaptive_mt_files(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Overloads
def list_adaptive_mt_files(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>
Pass arguments to list_adaptive_mt_files via a request object, either of type ListAdaptiveMtFilesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_adaptive_mt_files(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtFile>
Pass arguments to list_adaptive_mt_files via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the project from which to list the Adaptive MT files. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}
  • page_size (::Integer) — Optional.
  • page_token (::String) — Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtFilesResponse.next_page_token returned from the previous call to ListAdaptiveMtFiles method. The first page is returned if page_tokenis empty or missing.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtFilesRequest.new

# Call the list_adaptive_mt_files method.
result = client.list_adaptive_mt_files request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtFile.
  p item
end

#list_adaptive_mt_sentences

def list_adaptive_mt_sentences(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>
def list_adaptive_mt_sentences(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>

Lists all AdaptiveMtSentences under a given file/dataset.

Overloads
def list_adaptive_mt_sentences(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>
Pass arguments to list_adaptive_mt_sentences via a request object, either of type ListAdaptiveMtSentencesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_adaptive_mt_sentences(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::AdaptiveMtSentence>
Pass arguments to list_adaptive_mt_sentences via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file} The following format lists all sentences within a dataset. projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}
  • page_size (::Integer)
  • page_token (::String) — A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to ListTranslationMemories method. The first page is returned if page_token is empty or missing.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListAdaptiveMtSentencesRequest.new

# Call the list_adaptive_mt_sentences method.
result = client.list_adaptive_mt_sentences request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::AdaptiveMtSentence.
  p item
end

#list_glossaries

def list_glossaries(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>
def list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>

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

Overloads
def list_glossaries(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>
Pass arguments to list_glossaries via a request object, either of type ListGlossariesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::ListGlossariesRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>
Pass arguments to list_glossaries via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The name of the project from which to list all of the glossaries.
  • page_size (::Integer) — Optional. Requested page size. The server may return fewer glossaries than requested. If unspecified, the server picks an appropriate default.
  • page_token (::String) — Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossariesResponse.next_page_token] returned from the previous call to ListGlossaries method. The first page is returned if page_tokenis empty or missing.
  • filter (::String) — Optional. Filter specifying constraints of a list operation. Specify the constraint by the format of "key=value", where key must be "src" or "tgt", and the value must be a valid language code. For multiple restrictions, concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used here, which means using 'en-US' and 'en' can lead to different results, which depends on the language code you used when you create the glossary. For the unidirectional glossaries, the "src" and "tgt" add restrictions on the source and target language code separately. For the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional glossaries which exactly match the source language code as "en-US" and the target language code "zh-CN", but all equivalent term set glossaries which contain "en-US" and "zh-CN" in their language set will be picked. If missing, no filtering is performed.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::ListGlossariesRequest.new

# Call the list_glossaries method.
result = client.list_glossaries request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Translate::V3::Glossary.
  p item
end

#operations_client

def operations_client() -> ::Google::Cloud::Translate::V3::TranslationService::Rest::Operations

Get the associated client for long-running operations.

#translate_document

def translate_document(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateDocumentResponse
def translate_document(parent: nil, source_language_code: nil, target_language_code: nil, document_input_config: nil, document_output_config: nil, model: nil, glossary_config: nil, labels: nil, customized_attribution: nil, is_translate_native_pdf_only: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) -> ::Google::Cloud::Translate::V3::TranslateDocumentResponse

Translates documents in synchronous mode.

Overloads
def translate_document(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateDocumentResponse
Pass arguments to translate_document via a request object, either of type Google::Cloud::Translate::V3::TranslateDocumentRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::TranslateDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def translate_document(parent: nil, source_language_code: nil, target_language_code: nil, document_input_config: nil, document_output_config: nil, model: nil, glossary_config: nil, labels: nil, customized_attribution: nil, is_translate_native_pdf_only: nil, enable_shadow_removal_native_pdf: nil, enable_rotation_correction: nil) -> ::Google::Cloud::Translate::V3::TranslateDocumentResponse
Pass arguments to translate_document via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. Location to make a regional call.

    Format: 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 the same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.

  • source_language_code (::String) — Optional. 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. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response. Source language must be specified if the request contains a glossary or a custom model.
  • target_language_code (::String) — Required. The ISO-639 language code to use for translation of the input document, set to one of the language codes listed in Language Support.
  • document_input_config (::Google::Cloud::Translate::V3::DocumentInputConfig, ::Hash) — Required. Input configurations.
  • document_output_config (::Google::Cloud::Translate::V3::DocumentOutputConfig, ::Hash) — Optional. Output configurations. Defines if the output file should be stored within Cloud Storage as well as the desired output format. If not provided the translated file will only be returned through a byte-stream and its output mime type will be the same as the input file's mime type.
  • model (::String) — 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,

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

  • glossary_config (::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash) — Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.
  • labels (::Hash{::String => ::String}) — Optional. The labels with user-defined metadata for the request.

    Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

    See https://cloud.google.com/translate/docs/advanced/labels for more information.

  • customized_attribution (::String) — Optional. This flag is to support user customized attribution. If not provided, the default is Machine Translated by Google. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos
  • is_translate_native_pdf_only (::Boolean) — Optional. is_translate_native_pdf_only field for external customers. If true, the page limit of online native pdf translation is 300 and only native pdf pages will be translated.
  • enable_shadow_removal_native_pdf (::Boolean) — Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false
  • enable_rotation_correction (::Boolean) — Optional. If true, enable auto rotation correction in DVS.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::TranslateDocumentRequest.new

# Call the translate_document method.
result = client.translate_document request

# The returned object is of type Google::Cloud::Translate::V3::TranslateDocumentResponse.
p result

#translate_text

def translate_text(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateTextResponse
def translate_text(contents: nil, mime_type: nil, source_language_code: nil, target_language_code: nil, parent: nil, model: nil, glossary_config: nil, labels: nil) -> ::Google::Cloud::Translate::V3::TranslateTextResponse

Translates input text and returns translated text.

Overloads
def translate_text(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateTextResponse
Pass arguments to translate_text via a request object, either of type Google::Cloud::Translate::V3::TranslateTextRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Translate::V3::TranslateTextRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def translate_text(contents: nil, mime_type: nil, source_language_code: nil, target_language_code: nil, parent: nil, model: nil, glossary_config: nil, labels: nil) -> ::Google::Cloud::Translate::V3::TranslateTextResponse
Pass arguments to translate_text via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • contents (::Array<::String>) — Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.
  • mime_type (::String) — Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".
  • source_language_code (::String) — 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.
  • target_language_code (::String) — 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.
  • parent (::String) — 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.

  • model (::String) — 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

  • glossary_config (::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash) — Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.
  • labels (::Hash{::String => ::String}) — Optional. The labels with user-defined metadata for the request.

    Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.

    See https://cloud.google.com/translate/docs/advanced/labels for more information.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/translate/v3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Translate::V3::TranslationService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Translate::V3::TranslateTextRequest.new

# Call the translate_text method.
result = client.translate_text request

# The returned object is of type Google::Cloud::Translate::V3::TranslateTextResponse.
p result