Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DeepL glossaries #535

Merged
merged 1 commit into from
Nov 24, 2023
Merged

Conversation

michaelbaudino
Copy link
Contributor

@michaelbaudino michaelbaudino commented Nov 24, 2023

DeepL supports creating glossaries via their API. Each glossary is created for a given locale pair and can then be used by passing its id to the glossary_id param of the translate API endpoint.

Due to this constraint, the glossary to be used can only be defined when we know the source and target locales, thus using the glossary_id directly in i18n-tasks.yml is quite unconvenient.

This commit adds a deepl_glossary_ids configuration entry that allows listing all glossaries that may be used for translations with DeepL as a backend.

When a DeepL translation is performed, this commit adds some logic that fetches all glossaries on DeepL (they are associated with the API key) and selects one (if any) that:

  • is marked as ready by DeepL
  • can be used for the appropriate source locale
  • can be used for the appropriate target locale
  • is present in the deepl_glossary_ids configuration

DeepL supports creating glossaries via their API. Each glossary is created for a given locale pair and can then be used by passing its `id` to the `glossary_id` param of the `translate` API endpoint.

Due to this constraint, the glossary to be used can only be defined when we know the source and target locales, thus using the `glossary_id` directly in `i18n-tasks.yml` is quite unconvenient.

This commit adds a `deepl_glossary_ids` configuration entry that allows listing all glossaries that may be used for translations with DeepL as a backend.

When a DeepL translation is performed, this commit adds some logic that fetches all glossaries on DeepL (they are associated with the API key) and selects one (if any) that:
* is marked as `ready` by DeepL
* can be used for the appropriate source locale
* can be used for the appropriate target locale
* is present in the `deepl_glossary_ids` configuration
@glebm
Copy link
Owner

glebm commented Nov 24, 2023

Nice!

@glebm glebm merged commit 6c68163 into glebm:main Nov 24, 2023
6 checks passed
@michaelbaudino michaelbaudino deleted the support-deepl-glossaries branch November 27, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants