TranslationServiceClient(*, credentials: Optional[google.auth.credentials.Credentials] = None, transport: Optional[Union[str, google.cloud.translate_v3.services.translation_service.transports.base.TranslationServiceTransport]] = None, client_options: Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
Provides natural language translation operations.
Properties
transport
Returns the transport used by the client instance.
Returns | |
---|---|
Type | Description |
TranslationServiceTransport | The transport used by the client instance. |
Methods
TranslationServiceClient
TranslationServiceClient(*, credentials: Optional[google.auth.credentials.Credentials] = None, transport: Optional[Union[str, google.cloud.translate_v3.services.translation_service.transports.base.TranslationServiceTransport]] = None, client_options: Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
Instantiates the translation service client.
Parameters | |
---|---|
Name | Description |
credentials |
Optional[google.auth.credentials.Credentials]
The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. |
transport |
Union[str, TranslationServiceTransport]
The transport to use. If set to None, a transport is chosen automatically. |
client_options |
google.api_core.client_options.ClientOptions
Custom options for the client. It won't take effect if a |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
Exceptions | |
---|---|
Type | Description |
google.auth.exceptions.MutualTLSChannelError | If mutual TLS transport creation failed for any reason. |
__exit__
__exit__(type, value, traceback)
Releases underlying transport's resources.
batch_translate_document
batch_translate_document(request: Optional[Union[google.cloud.translate_v3.types.translation_service.BatchTranslateDocumentRequest, dict]] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())
Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
Parameters | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.types.BatchTranslateDocumentRequest, dict]
The request object. The BatchTranslateDocument 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 | |
---|---|
Type | Description |
google.api_core.operation.Operation | An 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_v3.types.translation_service.BatchTranslateTextRequest, dict]] = None, *, retry: google.api_core.retry.Retry = <_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 | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.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 | |
---|---|
Type | Description |
google.api_core.operation.Operation | An 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.
common_folder_path
common_folder_path(folder: str)
Returns a fully-qualified folder string.
common_location_path
common_location_path(project: str, location: str)
Returns a fully-qualified location string.
common_organization_path
common_organization_path(organization: str)
Returns a fully-qualified organization string.
common_project_path
common_project_path(project: str)
Returns a fully-qualified project string.
create_glossary
create_glossary(request: Optional[Union[google.cloud.translate_v3.types.translation_service.CreateGlossaryRequest, dict]] = None, *, parent: Optional[str] = None, glossary: Optional[google.cloud.translate_v3.types.translation_service.Glossary] = None, retry: google.api_core.retry.Retry = <_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 | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.types.CreateGlossaryRequest, dict]
The request object. Request message for CreateGlossary. |
parent |
str
Required. The project name. This corresponds to the |
glossary |
google.cloud.translate_v3.types.Glossary
Required. The glossary to create. This corresponds to the |
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 | |
---|---|
Type | Description |
google.api_core.operation.Operation | An 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_v3.types.translation_service.DeleteGlossaryRequest, dict]] = None, *, name: Optional[str] = None, retry: google.api_core.retry.Retry = <_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 | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.types.DeleteGlossaryRequest, dict]
The request object. Request message for DeleteGlossary. |
name |
str
Required. The name of the glossary to delete. This corresponds to the |
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 | |
---|---|
Type | Description |
google.api_core.operation.Operation | An 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_v3.types.translation_service.DetectLanguageRequest, dict]] = None, *, parent: Optional[str] = None, model: Optional[str] = None, mime_type: Optional[str] = None, content: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())
Detects the language of text within a request.
Parameters | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.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: |
model |
str
Optional. The language detection model to be used. Format: |
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 |
content |
str
The content of the input stored as a string. This corresponds to the |
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 | |
---|---|
Type | Description |
google.cloud.translate_v3.types.DetectLanguageResponse | The 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.
Parameter | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
TranslationServiceClient | The 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.
Parameter | |
---|---|
Name | Description |
info |
dict
The service account private key info. |
Returns | |
---|---|
Type | Description |
TranslationServiceClient | The 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.
Parameter | |
---|---|
Name | Description |
filename |
str
The path to the service account private key json file. |
Returns | |
---|---|
Type | Description |
TranslationServiceClient | The constructed client. |
get_glossary
get_glossary(request: Optional[Union[google.cloud.translate_v3.types.translation_service.GetGlossaryRequest, dict]] = None, *, name: Optional[str] = None, retry: google.api_core.retry.Retry = <_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 | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.types.GetGlossaryRequest, dict]
The request object. Request message for GetGlossary. |
name |
str
Required. The name of the glossary to retrieve. This corresponds to the |
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 | |
---|---|
Type | Description |
google.cloud.translate_v3.types.Glossary | Represents a glossary built from user provided data. |
get_supported_languages
get_supported_languages(request: Optional[Union[google.cloud.translate_v3.types.translation_service.GetSupportedLanguagesRequest, dict]] = None, *, parent: Optional[str] = None, model: Optional[str] = None, display_language_code: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())
Returns a list of supported languages for translation.
Parameters | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.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: |
model |
str
Optional. Get supported languages of this model. The format depends on model type: - AutoML Translation models: |
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 |
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 | |
---|---|
Type | Description |
google.cloud.translate_v3.types.SupportedLanguages | The response message for discovering supported languages. |
glossary_path
glossary_path(project: str, location: str, glossary: str)
Returns a fully-qualified glossary string.
list_glossaries
list_glossaries(request: Optional[Union[google.cloud.translate_v3.types.translation_service.ListGlossariesRequest, dict]] = None, *, parent: Optional[str] = None, retry: google.api_core.retry.Retry = <_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 | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.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 |
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 | |
---|---|
Type | Description |
google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager | Response 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.
parse_common_folder_path
parse_common_folder_path(path: str)
Parse a folder path into its component segments.
parse_common_location_path
parse_common_location_path(path: str)
Parse a location path into its component segments.
parse_common_organization_path
parse_common_organization_path(path: str)
Parse a organization path into its component segments.
parse_common_project_path
parse_common_project_path(path: str)
Parse a project path into its component segments.
parse_glossary_path
parse_glossary_path(path: str)
Parses a glossary path into its component segments.
translate_document
translate_document(request: Optional[Union[google.cloud.translate_v3.types.translation_service.TranslateDocumentRequest, dict]] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())
Translates documents in synchronous mode.
Parameters | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.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 | |
---|---|
Type | Description |
google.cloud.translate_v3.types.TranslateDocumentResponse | A translated document response message. |
translate_text
translate_text(request: Optional[Union[google.cloud.translate_v3.types.translation_service.TranslateTextRequest, dict]] = None, *, parent: Optional[str] = None, target_language_code: Optional[str] = None, contents: Optional[Sequence[str]] = None, model: Optional[str] = None, mime_type: Optional[str] = None, source_language_code: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())
Translates input text and returns translated text.
Parameters | |
---|---|
Name | Description |
request |
Union[google.cloud.translate_v3.types.TranslateTextRequest, dict]
The request object. The request message for synchronous translation. |
parent |
str
Required. Project or location to make a call. Must refer to a caller's project. Format: |
target_language_code |
str
Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. This corresponds to the |
contents |
Sequence[str]
Required. The content of the input in string format. We recommend the total content be less than 30k codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text. This corresponds to the |
model |
str
Optional. The |
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 |
source_language_code |
str
Optional. The BCP-47 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. This corresponds to the |
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. |