Google Cloud Translate API client library for translating text between thousands of language pairs with support for adaptive MT, AutoML, and glossaries
—
Complete type definitions for all request and response objects used across the V3 API. These types define the structure of data sent to and received from the Google Cloud Translation API V3 endpoints.
from google.cloud import translate_v3class TranslateTextRequest:
"""
Request message for TranslateText method.
Attributes:
contents (list): Text content to translate (required)
mime_type (str): MIME type of content ('text/plain' or 'text/html')
source_language_code (str): Source language code (BCP-47)
target_language_code (str): Target language code (BCP-47, required)
parent (str): Project/location resource name (required)
model (str): Custom model to use for translation
glossary_config (TranslateTextGlossaryConfig): Glossary configuration
transliteration_config (TransliterationConfig): Transliteration configuration
labels (dict): Labels for request tracking
"""
class TranslateTextResponse:
"""
Response message for TranslateText method.
Attributes:
translations (list): List of Translation objects
glossary_translations (list): Translations using glossary
language_code (str): Detected source language code
"""
class Translation:
"""
A single translation response.
Attributes:
translated_text (str): Translated text
model (str): Model used for translation
detected_language_code (str): Detected source language
glossary_config (TranslateTextGlossaryConfig): Applied glossary configuration
"""class TranslateDocumentRequest:
"""
Request message for TranslateDocument method.
Attributes:
parent (str): Project/location resource name (required)
source_language_code (str): Source language code
target_language_code (str): Target language code (required)
document_input_config (DocumentInputConfig): Document input configuration (required)
document_output_config (DocumentOutputConfig): Document output configuration
model (str): Custom model to use
glossary_config (TranslateTextGlossaryConfig): Glossary configuration
labels (dict): Labels for request tracking
customized_attribution (str): Attribution for customized model
is_translate_native_pdf_only (bool): Translate native PDFs only
enable_shadow_removal_native_pdf (bool): Enable shadow removal for PDFs
enable_rotation_correction (bool): Enable rotation correction
"""
class TranslateDocumentResponse:
"""
Response message for TranslateDocument method.
Attributes:
document_translation (DocumentTranslation): Document translation result
glossary_document_translation (DocumentTranslation): Translation using glossary
model (str): Model used for translation
glossary_config (TranslateTextGlossaryConfig): Applied glossary configuration
"""
class DocumentTranslation:
"""
Document translation result.
Attributes:
byte_stream_outputs (list): Translated document content
mime_type (str): MIME type of output
detected_language_code (str): Detected source language
"""class DetectLanguageRequest:
"""
Request message for DetectLanguage method.
Attributes:
parent (str): Project/location resource name (required)
model (str): Optional model to use for detection
content (str): Text content to analyze
mime_type (str): MIME type of content
labels (dict): Labels for request tracking
"""
class DetectLanguageResponse:
"""
Response message for DetectLanguage method.
Attributes:
languages (list): List of DetectedLanguage objects
"""
class DetectedLanguage:
"""
Language detection result.
Attributes:
language_code (str): Detected language code (BCP-47)
confidence (float): Detection confidence score (0.0 to 1.0)
"""class GetSupportedLanguagesRequest:
"""
Request message for GetSupportedLanguages method.
Attributes:
parent (str): Project/location resource name (required)
display_language_code (str): Language code for language names
model (str): Optional model to get languages for
"""
class SupportedLanguages:
"""
Response message for GetSupportedLanguages method.
Attributes:
languages (list): List of SupportedLanguage objects
"""
class SupportedLanguage:
"""
A supported language.
Attributes:
language_code (str): Language code (BCP-47)
display_name (str): Human-readable language name
support_source (bool): Can be used as source language
support_target (bool): Can be used as target language
"""class RomanizeTextRequest:
"""
Request message for RomanizeText method.
Attributes:
parent (str): Project/location resource name (required)
contents (list): Text content to romanize (required)
source_language_code (str): Source language code
"""
class RomanizeTextResponse:
"""
Response message for RomanizeText method.
Attributes:
romanizations (list): List of Romanization objects
"""
class Romanization:
"""
Romanization result.
Attributes:
romanized_text (str): Romanized text in Latin script
detected_language_code (str): Detected source language
"""class BatchTranslateTextRequest:
"""
Request message for BatchTranslateText method.
Attributes:
parent (str): Project/location resource name (required)
source_language_code (str): Source language code (required)
target_language_codes (list): List of target language codes (required)
input_configs (list): List of input configurations (required)
output_config (OutputConfig): Output configuration (required)
models (dict): Custom models for specific language pairs
glossaries (dict): Glossaries for specific language pairs
labels (dict): Labels for request tracking
"""
class BatchTranslateResponse:
"""
Response message for BatchTranslateText method.
Attributes:
total_characters (int): Total characters processed
translated_characters (int): Successfully translated characters
failed_characters (int): Failed translation characters
submit_time (Timestamp): Operation submit time
end_time (Timestamp): Operation end time
"""
class BatchTranslateMetadata:
"""
Metadata for batch translation operation.
Attributes:
state (OperationState): Current operation state
translated_characters (int): Characters translated so far
failed_characters (int): Characters that failed translation
total_characters (int): Total characters to translate
submit_time (Timestamp): Operation submit time
"""class BatchTranslateDocumentRequest:
"""
Request message for BatchTranslateDocument method.
Attributes:
parent (str): Project/location resource name (required)
source_language_code (str): Source language code (required)
target_language_codes (list): List of target language codes (required)
input_configs (list): List of batch document input configurations (required)
output_config (BatchDocumentOutputConfig): Output configuration (required)
models (dict): Custom models for specific language pairs
glossaries (dict): Glossaries for specific language pairs
format_conversions (dict): Format conversion specifications
customized_attribution (str): Attribution for customized model
enable_shadow_removal_native_pdf (bool): Enable shadow removal for PDFs
enable_rotation_correction (bool): Enable rotation correction
"""
class BatchTranslateDocumentResponse:
"""
Response message for BatchTranslateDocument method.
Attributes:
total_pages (int): Total pages processed
translated_pages (int): Successfully translated pages
failed_pages (int): Failed translation pages
total_billable_pages (int): Total billable pages
submit_time (Timestamp): Operation submit time
end_time (Timestamp): Operation end time
"""
class BatchTranslateDocumentMetadata:
"""
Metadata for batch document translation operation.
Attributes:
state (OperationState): Current operation state
total_pages (int): Total pages to translate
translated_pages (int): Pages translated so far
failed_pages (int): Pages that failed translation
total_billable_pages (int): Total billable pages
submit_time (Timestamp): Operation submit time
"""class CreateGlossaryRequest:
"""
Request message for CreateGlossary method.
Attributes:
parent (str): Project/location resource name (required)
glossary (Glossary): Glossary configuration (required)
"""
class UpdateGlossaryRequest:
"""
Request message for UpdateGlossary method.
Attributes:
glossary (Glossary): Updated glossary configuration (required)
update_mask (FieldMask): Fields to update
"""
class ListGlossariesRequest:
"""
Request message for ListGlossaries method.
Attributes:
parent (str): Project/location resource name (required)
page_size (int): Maximum number of glossaries to return
page_token (str): Token for pagination
filter (str): Filter expression for glossaries
"""
class ListGlossariesResponse:
"""
Response message for ListGlossaries method.
Attributes:
glossaries (list): List of Glossary objects
next_page_token (str): Token for next page
"""
class GetGlossaryRequest:
"""
Request message for GetGlossary method.
Attributes:
name (str): Glossary resource name (required)
"""
class DeleteGlossaryRequest:
"""
Request message for DeleteGlossary method.
Attributes:
name (str): Glossary resource name (required)
"""
class DeleteGlossaryResponse:
"""
Response message for DeleteGlossary method.
Attributes:
name (str): Deleted glossary name
submit_time (Timestamp): Operation submit time
end_time (Timestamp): Operation end time
"""class CreateGlossaryEntryRequest:
"""
Request message for CreateGlossaryEntry method.
Attributes:
parent (str): Glossary resource name (required)
glossary_entry (GlossaryEntry): Entry configuration (required)
"""
class UpdateGlossaryEntryRequest:
"""
Request message for UpdateGlossaryEntry method.
Attributes:
glossary_entry (GlossaryEntry): Updated entry configuration (required)
"""
class ListGlossaryEntriesRequest:
"""
Request message for ListGlossaryEntries method.
Attributes:
parent (str): Glossary resource name (required)
page_size (int): Maximum number of entries to return
page_token (str): Token for pagination
"""
class ListGlossaryEntriesResponse:
"""
Response message for ListGlossaryEntries method.
Attributes:
glossary_entries (list): List of GlossaryEntry objects
next_page_token (str): Token for next page
"""
class GetGlossaryEntryRequest:
"""
Request message for GetGlossaryEntry method.
Attributes:
name (str): Glossary entry resource name (required)
"""
class DeleteGlossaryEntryRequest:
"""
Request message for DeleteGlossaryEntry method.
Attributes:
name (str): Glossary entry resource name (required)
"""class DocumentInputConfig:
"""
Document input configuration.
Attributes:
content (bytes): Document content as bytes
gcs_source (GcsSource): Google Cloud Storage source
mime_type (str): Document MIME type (required)
"""
class DocumentOutputConfig:
"""
Document output configuration.
Attributes:
gcs_destination (GcsDestination): Google Cloud Storage destination
mime_type (str): Output MIME type
"""
class BatchDocumentInputConfig:
"""
Batch document input configuration.
Attributes:
gcs_source (GcsSource): Google Cloud Storage source (required)
mime_type (str): Document MIME type (required)
"""
class BatchDocumentOutputConfig:
"""
Batch document output configuration.
Attributes:
gcs_destination (GcsDestination): Google Cloud Storage destination (required)
"""class InputConfig:
"""
Input configuration for batch operations.
Attributes:
mime_type (str): Input MIME type
gcs_source (GcsSource): Google Cloud Storage source
"""
class OutputConfig:
"""
Output configuration for batch operations.
Attributes:
gcs_destination (GcsDestination): Google Cloud Storage destination (required)
"""
class GcsSource:
"""
Google Cloud Storage source.
Attributes:
input_uri (str): GCS URI (gs://bucket/path)
"""
class GcsDestination:
"""
Google Cloud Storage destination.
Attributes:
output_uri_prefix (str): GCS URI prefix for output
"""class TranslateTextGlossaryConfig:
"""
Glossary configuration for translation.
Attributes:
glossary (str): Glossary resource name (required)
ignore_case (bool): Whether to ignore case when matching
"""
class GlossaryInputConfig:
"""
Glossary input configuration.
Attributes:
gcs_source (GcsSource): Google Cloud Storage source (required)
mime_type (str): Glossary MIME type (required)
"""class TransliterationConfig:
"""
Transliteration configuration.
Attributes:
enable_transliteration (bool): Whether to enable transliteration (required)
"""Install with Tessl CLI
npx tessl i tessl/pypi-google-cloud-translate