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.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all TranslationService clients ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config| config.timeout = 10.0 end
#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.
def batch_translate_document(request, options = nil) -> ::Gapic::Operation
batch_translate_document
via a request object, either of type
BatchTranslateDocumentRequest or an equivalent Hash.
- 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
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).
-
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. File format conversion map to be applied to all input files.
Map's key is the original mime_type. Map's value is the target mime_type of
translated documents.
Supported file format conversion includes:
application/pdf
toapplication/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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Operation)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def batch_translate_text(request, options = nil) -> ::Gapic::Operation
batch_translate_text
via a request object, either of type
BatchTranslateTextRequest or an equivalent Hash.
- 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
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).
-
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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Operation)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
- (config) — Configure the Client client.
- config (Client::Configuration)
#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.
def create_glossary(request, options = nil) -> ::Gapic::Operation
create_glossary
via a request object, either of type
CreateGlossaryRequest or an equivalent Hash.
- 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
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).
- parent (::String) — Required. The project name.
- glossary (::Google::Cloud::Translate::V3::Glossary, ::Hash) — Required. The glossary to create.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Operation)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def delete_glossary(request, options = nil) -> ::Gapic::Operation
delete_glossary
via a request object, either of type
DeleteGlossaryRequest or an equivalent Hash.
- 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
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).
- name (::String) — Required. The name of the glossary to delete.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Operation)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def detect_language(request, options = nil) -> ::Google::Cloud::Translate::V3::DetectLanguageResponse
detect_language
via a request object, either of type
DetectLanguageRequest or an equivalent Hash.
- 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
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).
-
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}
orprojects/{project-number-or-id}
.For global calls, use
projects/{project-number-or-id}/locations/global
orprojects/{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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Translate::V3::DetectLanguageResponse)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def get_glossary(request, options = nil) -> ::Google::Cloud::Translate::V3::Glossary
get_glossary
via a request object, either of type
GetGlossaryRequest or an equivalent Hash.
- 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
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).
- name (::String) — Required. The name of the glossary to retrieve.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Translate::V3::Glossary)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def get_supported_languages(request, options = nil) -> ::Google::Cloud::Translate::V3::SupportedLanguages
get_supported_languages
via a request object, either of type
GetSupportedLanguagesRequest or an equivalent Hash.
- 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
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).
-
parent (::String) — Required. Project or location to make a call. Must refer to a caller's
project.
Format:
projects/{project-number-or-id}
orprojects/{project-number-or-id}/locations/{location-id}
.For global calls, use
projects/{project-number-or-id}/locations/global
orprojects/{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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Translate::V3::SupportedLanguages)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#initialize
def initialize() { |config| ... } -> Client
Create a new TranslationService REST client object.
- (config) — Configure the TranslationService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# 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_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.
def list_glossaries(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>
list_glossaries
via a request object, either of type
ListGlossariesRequest or an equivalent Hash.
- 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>
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).
- 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 ifpage_token
is 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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def translate_document(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateDocumentResponse
translate_document
via a request object, either of type
Google::Cloud::Translate::V3::TranslateDocumentRequest or an equivalent Hash.
- 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
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).
-
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
orprojects/{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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Translate::V3::TranslateDocumentResponse)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.
#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.
def translate_text(request, options = nil) -> ::Google::Cloud::Translate::V3::TranslateTextResponse
translate_text
via a request object, either of type
Google::Cloud::Translate::V3::TranslateTextRequest or an equivalent Hash.
- 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
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).
- 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}
orprojects/{project-number-or-id}/locations/{location-id}
.For global calls, use
projects/{project-number-or-id}/locations/global
orprojects/{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.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Translate::V3::TranslateTextResponse)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.