Skip to content

DeepL: added Glossary and HTML functionality#100

Open
thornch wants to merge 3 commits into
Squidex:mainfrom
thornch:deepl-extension
Open

DeepL: added Glossary and HTML functionality#100
thornch wants to merge 3 commits into
Squidex:mainfrom
thornch:deepl-extension

Conversation

@thornch

@thornch thornch commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

DeepL: Added support for the parameters tag_handling and glossary_id via application.config:

"translations.deepl.tagHandling": "html" // Enables translation of HTML content, e.g. from rich text editors.
"translations.deepl.glossaryById": "{client-glossary-id}" // Uses a specific DeepL glossary ID for translations.
"translations.deepl.glossaryByName": "{client-glossary-name}" // Resolves the glossary ID by glossary name before translation.

DeepL glossary handling:
When a glossary is replaced or recreated, its glossary ID may change. To keep glossary functionality stable in such cases, keep the glossary name unchanged and configure glossaryByName instead of glossaryById.

If a glossary name is configured, the glossary lookup is performed using the glossary name together with the source and target language pair.

The resolved glossary ID is cached in memory. If the glossary becomes invalid (for example because it was deleted or recreated), the cache is invalidated when a translation request fails and the glossary ID is resolved again on the next request.

Note: DeepL requires source_lang to be specified explicitly when a glossary is used for translation.

@thornch

thornch commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

All code review comments and requested changes from #93 have been resolved and implemented as part of this pull request.

private const string UrlPaid = "https://api.deepl.com/v2/translate";
private const string UrlFree = "https://api-free.deepl.com/v2/translate";
private readonly DeepLTranslationOptions options = options.Value;
private readonly ConcurrentDictionary<string, string?> glossaryCache = new ();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is this cache and how much entries can we expect here? I have not digged into this glossary stuff.

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.

3 participants