[Python] Glossary not considered when using translate_document

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Google Translate APItranslate_v3 Python library. Translating text with translate_text works. Terms that have been specified in a glossary are considered correctly in the target text:

    trans_response = client.translate_text(
    request={
    "parent": parent,
    "contents": [source_text],
    "mime_type": "text/plain",
    "source_language_code": google_source_lang,
    "target_language_code": google_target_lang,
    "glossary_config": glossary_config,
    }
    )


    I modified my code to translate documents with translate_document. In this case the glossary is not considered in the target text, although the glossary, glossary_config, etc. have been setup in exactly the same way as above shown text translation. The logs show that the glossary has been created and there are no errors. I get a translated document, but the glossary is not considered:

    trans_response = client.translate_document(
    request={
    "parent": parent,
    "document_input_config": document_input_config,
    "source_language_code": google_source_lang,
    "target_language_code": google_target_lang,
    "glossary_config": glossary_config,
    }
    )


    I tried several source and target combinations and various document formats. The result is always the same. Works with plain text translation (translate_text) but not with document translation (translate_document), then the glossary is not considered in the translated documents.

    Continue reading...

Compartilhe esta Página