langchain_community.document_transformers.google_translate.GoogleTranslateTransformer¶

class langchain_community.document_transformers.google_translate.GoogleTranslateTransformer(project_id: str, *, location: str = 'global', model_id: Optional[str] = None, glossary_id: Optional[str] = None, api_endpoint: Optional[str] = None)[source]¶

Translate text documents using Google Cloud Translation.

Parameters
  • project_id (str) – Google Cloud Project ID.

  • location (str) – (Optional) Translate model location.

  • model_id (Optional[str]) – (Optional) Translate model ID to use.

  • glossary_id (Optional[str]) – (Optional) Translate glossary ID to use.

  • api_endpoint (Optional[str]) – (Optional) Regional endpoint to use.

Methods

__init__(project_id, *[, location, ...])

param project_id

Google Cloud Project ID.

atransform_documents(documents, **kwargs)

Asynchronously transform a list of documents.

transform_documents(documents, **kwargs)

Translate text documents using Google Translate.

__init__(project_id: str, *, location: str = 'global', model_id: Optional[str] = None, glossary_id: Optional[str] = None, api_endpoint: Optional[str] = None) None[source]¶
Parameters
  • project_id (str) – Google Cloud Project ID.

  • location (str) – (Optional) Translate model location.

  • model_id (Optional[str]) – (Optional) Translate model ID to use.

  • glossary_id (Optional[str]) – (Optional) Translate glossary ID to use.

  • api_endpoint (Optional[str]) – (Optional) Regional endpoint to use.

Return type

None

async atransform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document]¶

Asynchronously transform a list of documents.

Parameters
  • documents (Sequence[Document]) – A sequence of Documents to be transformed.

  • kwargs (Any) –

Returns

A list of transformed Documents.

Return type

Sequence[Document]

transform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document][source]¶

Translate text documents using Google Translate.

Parameters
  • source_language_code – ISO 639 language code of the input document.

  • target_language_code – ISO 639 language code of the output document. For supported languages, refer to: https://cloud.google.com/translate/docs/languages

  • mime_type – (Optional) Media Type of input text. Options: text/plain, text/html

  • documents (Sequence[Document]) –

  • kwargs (Any) –

Return type

Sequence[Document]

Examples using GoogleTranslateTransformer¶