Class TranslationServiceAsyncClient

Provides natural language translation operations.

Inheritance

builtins.object > TranslationServiceAsyncClient

Properties

transport

Returns the transport used by the client instance.

Returns
TypeDescription
TranslationServiceTransportThe transport used by the client instance.

Methods

batch_translate_document

batch_translate_document(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.BatchTranslateDocumentRequest, dict]] = None, *, parent: Optional[str] = None, source_language_code: Optional[str] = None, target_language_codes: Optional[Sequence[str]] = None, input_configs: Optional[Sequence[google.cloud.translate_v3beta1.types.translation_service.BatchDocumentInputConfig]] = None, output_config: Optional[google.cloud.translate_v3beta1.types.translation_service.BatchDocumentOutputConfig] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates a large volume of documents in asynchronous batch mode. This function provides real- time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.BatchTranslateDocumentRequest, dict]

The request object. The BatchTranslateDocument request.

parent `str`

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. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

source_language_code `str`

Required. The BCP-47 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support (https://cloud.google.com/translate/docs/languages). This corresponds to the source_language_code field on the request instance; if request is provided, this should not be set.

target_language_codes :class:`Sequence[str]`

Required. The BCP-47 language code to use for translation of the input document. Specify up to 10 language codes here. This corresponds to the target_language_codes field on the request instance; if request is provided, this should not be set.

input_configs :class:`Sequence[google.cloud.translate_v3beta1.types.BatchDocumentInputConfig]`

Required. Input configurations. The total number of files matched should be <= 100. The total content size to translate should be <= 100M Unicode codepoints. The files must use UTF-8 encoding. This corresponds to the input_configs field on the request instance; if request is provided, this should not be set.

output_config BatchDocumentOutputConfig

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. This corresponds to the output_config field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be BatchTranslateDocumentResponse Stored in the `google.longrunning.Operation.response][google.longrunning.Operation.response]` field returned by BatchTranslateDocument if at least one document is translated successfully.

batch_translate_text

batch_translate_text(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.BatchTranslateTextRequest, dict]] = None, *, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.BatchTranslateTextRequest, dict]

The request object. The batch translation request.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be BatchTranslateResponse Stored in the `google.longrunning.Operation.response][google.longrunning.Operation.response]` field returned by BatchTranslateText if at least one sentence is translated successfully.

common_billing_account_path

common_billing_account_path(billing_account: str)

Returns a fully-qualified billing_account string.

Parameter
NameDescription
billing_account str

common_folder_path

common_folder_path(folder: str)

Returns a fully-qualified folder string.

Parameter
NameDescription
folder str

common_location_path

common_location_path(project: str, location: str)

Returns a fully-qualified location string.

Parameters
NameDescription
project str
location str

common_organization_path

common_organization_path(organization: str)

Returns a fully-qualified organization string.

Parameter
NameDescription
organization str

common_project_path

common_project_path(project: str)

Returns a fully-qualified project string.

Parameter
NameDescription
project str

create_glossary

create_glossary(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.CreateGlossaryRequest, dict]] = None, *, parent: Optional[str] = None, glossary: Optional[google.cloud.translate_v3beta1.types.translation_service.Glossary] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

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

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.CreateGlossaryRequest, dict]

The request object. Request message for CreateGlossary.

parent `str`

Required. The project name. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

glossary Glossary

Required. The glossary to create. This corresponds to the glossary field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be Glossary Represents a glossary built from user provided data.

delete_glossary

delete_glossary(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.DeleteGlossaryRequest, dict]] = None, *, name: Optional[str] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

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

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.DeleteGlossaryRequest, dict]

The request object. Request message for DeleteGlossary.

name `str`

Required. The name of the glossary to delete. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be DeleteGlossaryResponse Stored in the `google.longrunning.Operation.response][google.longrunning.Operation.response]` field returned by DeleteGlossary.

detect_language

detect_language(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.DetectLanguageRequest, dict]] = None, *, parent: Optional[str] = None, model: Optional[str] = None, mime_type: Optional[str] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Detects the language of text within a request.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.DetectLanguageRequest, dict]

The request object. The request message for language detection.

parent `str`

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. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

model `str`

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. This corresponds to the model field on the request instance; if request is provided, this should not be set.

mime_type `str`

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html". This corresponds to the mime_type field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.translate_v3beta1.types.DetectLanguageResponseThe response message for language detection.

from_service_account_file

from_service_account_file(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameters
NameDescription
filename str

The path to the service account private key json file.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TranslationServiceAsyncClientThe constructed client.

from_service_account_info

from_service_account_info(info: dict, *args, **kwargs)

Creates an instance of this client using the provided credentials info.

Parameters
NameDescription
info dict

The service account private key info.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TranslationServiceAsyncClientThe constructed client.

from_service_account_json

from_service_account_json(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameters
NameDescription
filename str

The path to the service account private key json file.

args

Additional arguments to pass to the constructor.

kwargs

Additional arguments to pass to the constructor.

Returns
TypeDescription
TranslationServiceAsyncClientThe constructed client.

get_glossary

get_glossary(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.GetGlossaryRequest, dict]] = None, *, name: Optional[str] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

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

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.GetGlossaryRequest, dict]

The request object. Request message for GetGlossary.

name `str`

Required. The name of the glossary to retrieve. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.translate_v3beta1.types.GlossaryRepresents a glossary built from user provided data.

get_supported_languages

get_supported_languages(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.GetSupportedLanguagesRequest, dict]] = None, *, parent: Optional[str] = None, display_language_code: Optional[str] = None, model: Optional[str] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Returns a list of supported languages for translation.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.GetSupportedLanguagesRequest, dict]

The request object. The request message for discovering supported languages.

parent `str`

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. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

display_language_code `str`

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. This corresponds to the display_language_code field on the request instance; if request is provided, this should not be set.

model `str`

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. This corresponds to the model field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.translate_v3beta1.types.SupportedLanguagesThe response message for discovering supported languages.

get_transport_class

get_transport_class()

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

Parameter
NameDescription
label str

glossary_path

glossary_path(project: str, location: str, glossary: str)

Returns a fully-qualified glossary string.

Parameters
NameDescription
project str
location str
glossary str

list_glossaries

list_glossaries(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.ListGlossariesRequest, dict]] = None, *, parent: Optional[str] = None, filter: Optional[str] = None, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

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

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.ListGlossariesRequest, dict]

The request object. Request message for ListGlossaries.

parent `str`

Required. The name of the project from which to list all of the glossaries. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

filter `str`

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. This corresponds to the filter field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.translate_v3beta1.services.translation_service.pagers.ListGlossariesAsyncPagerResponse message for ListGlossaries. Iterating over this object will yield results and resolve additional pages automatically.

parse_common_billing_account_path

parse_common_billing_account_path(path: str)

Parse a billing_account path into its component segments.

Parameter
NameDescription
path str

parse_common_folder_path

parse_common_folder_path(path: str)

Parse a folder path into its component segments.

Parameter
NameDescription
path str

parse_common_location_path

parse_common_location_path(path: str)

Parse a location path into its component segments.

Parameter
NameDescription
path str

parse_common_organization_path

parse_common_organization_path(path: str)

Parse a organization path into its component segments.

Parameter
NameDescription
path str

parse_common_project_path

parse_common_project_path(path: str)

Parse a project path into its component segments.

Parameter
NameDescription
path str

parse_glossary_path

parse_glossary_path(path: str)

Parses a glossary path into its component segments.

Parameter
NameDescription
path str

translate_document

translate_document(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.TranslateDocumentRequest, dict]] = None, *, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates documents in synchronous mode.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.TranslateDocumentRequest, dict]

The request object. A document translation request.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.translate_v3beta1.types.TranslateDocumentResponseA translated document response message.

translate_text

translate_text(request: Optional[Union[google.cloud.translate_v3beta1.types.translation_service.TranslateTextRequest, dict]] = None, *, retry: Union[google.api_core.retry.Retry, object] = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates input text and returns translated text.

Parameters
NameDescription
request Union[google.cloud.translate_v3beta1.types.TranslateTextRequest, dict]

The request object. The request message for synchronous translation.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.