Skip to content

Support for multiple glossary IDs #162

Description

@DomenOro

As of June 23, multiple glossaries should be supported by the v2/translate API. However, the Python library currently does not seem support that (using the latest version 1.30.0).

Simply using a list of IDs in the glossary paremeter expectedly raises an exception:
deepl.exceptions.DeepLException: Bad request, message: Value for 'glossary_id' not supported.

To work around that I've simply added a new check in the _check_language_and_formality method:

class Translator:
    def _check_language_and_formality[...]
        if isinstance(glossary, list):
            request_data["glossary_ids"] = glossary
        elif isinstance(glossary, GlossaryInfo) or isinstance(
                glossary, MultilingualGlossaryInfo
        ):
            request_data["glossary_id"] = glossary.glossary_id
        elif glossary is not None:
            request_data["glossary_id"] = glossary
    [...]

The API is happy to process the request afterwards :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions