Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
- deepL introduced the possibility to use a custom glossary while translating text and documents
Proposed resolution
- Allow creation of custom glossaries via deepL API in drupal
- Add config / option to specify glossary id in tmgmt_deepl UI
- Pass glossary_id in API calls while requesting translatinos
User interface changes
- Add select field for selecting glossary on the translator config form
- Administration page for glossaries
Issue fork tmgmt_deepl-3232134
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
SteffenRComment #3
SteffenRComment #4
SteffenRDue to limitations of the deepL API we cannot use the glossaries created on the website or in the deepL apps.
In this case we have to implement a custom solution based on drupal entities for creating glossaries via the API documented in https://www.deepl.com/docs-api/managing-glossaries/.
More information about the topic can be found here: https://support.deepl.com/hc/en-us/articles/4405021321746-Managing-gloss...
Comment #5
SteffenRComment #6
SteffenRComment #7
daveianoAny updates on this?
Would love to see this feature added :)
Comment #8
SteffenR@daveiano
Feel free to contribute.
RIght now, i've not planned to integrate the feature, cause i'm involved in a time consuming project with not so much time left for extra contributions.
While implementing the feature, we should take care of the following things
As you can see, there are several things, we need to take care, while integrating the glossaries.
For storage purposes a custom entity type would be best fit - syncinc between drupal < > DeepL could be achieved by running a cron/ manually sync process.
API documentation: https://www.deepl.com/de/docs-api/managing-glossaries/
Comment #9
SteffenRSince i'm currently working on the issue, i'll set the status to Active.
Current progress is available at https://git.drupalcode.org/issue/tmgmt_deepl-3232134/-/tree/3232134-glos...
Comment #10
daveianoI had a quick look over the commits. It seems the Glossary management part on the Drupal side is done, also the sync to Deepl?
What I don't get is why the deepl_glossary entity has
translatable = FALSE
? How to define the translations for the glossary items?Comment #11
SteffenR@daveiano:
The deepl_glossary entity won't get translated, cause you build up a glossary entity with its entries for a specific language pair. While running checkout, those glossary entities will be available for selection in the translation checkout process (since we have access to source/ target language in the checkout, we can check for possible glossary entities to let the user choose from).
Just have a look at the API documentation https://www.deepl.com/docs-api/managing-glossaries/
This is done roughly on my dev machine, but needs some polishing to get pushed to the branch.
Furthermore a cron will be added, to fetch glossaries from the deepl API automatically.
Comment #12
daveianoI am afraid I don't get it. How will the glossary entries then be translated?
I cloned the current state of the branch and tested a bit around. I noticed that the implementation of the "selectable glossaries" is implemented in the
checkoutSettingsForm
. To be honest, I had never seen this form. In my use case, people usually translate a node directly via the node translate tab and the "Request translation" button. The checkoutSettingsForm is only visible when adding a "Continuous Job", so no way to use glossaries with a "manual translation"?Also: The adding of a glossary entry without adding a definition fails silently (I don't think the definition should be required).
Sorry for asking so many question, just want to understand it :D
Comment #13
SteffenR@daveiano:
Let me explain.
The glossary entity stores entries for a specific language combination e.g. EN (English) → DE (German).
A translation of those entities would make no sense for this case.
DeepL uses the entries of the glossary and simply replaces our defined subject with the given definition.
This can be used, if you want a really specific translation for a given term, that differs from the translation deepl would provide while translating.
For that purpose, we have to provide a matching glossary with its entries while requesting a translation.
You can think of multiple glossaries per language pair or just single combination. But in all use cases, we need a selection of the glossary, we want to use for a given job.
The checkout form is the best place to add those informations to the current translation job (you won't need to build a continous job for that purpose). It's just the default translation workflow provided by the underlying tmgmt module. You may take tmgmt_file as an example, how to apply custom checkout settings or other tmgmt related translator providers.
Hope it helps to understand, how the whole glossary "thing" is working. The API documentation also provides lots of infos, how this is working internally. Just check the link in my previous comments.
A recent blog post of deepL also describes the use of glossaries https://www.deepl.com/en/blog/translate-your-way-with-the-deepl-glossary
Comment #15
daveiano@SteffenR
Ah, I got you, thank you for the explanation.
With that in mind I had a look over MR10 and tested it again:
One reason for confusion on my site was the TMGMT setting "Allow quick checkout" (/admin/tmgmt/settings). If this is enabled, you will never see the checkout form (Only for continuous jobs, hence my confusion). I disabled this and now I can see and select a glossary for a translation job. Will we be able to select multiple glossaries per translation job?
And I think I found a Bug, I created a glossary with one entry (DE > EN):
subject: Eignungsprüfung (allgemein)
definition: aptitude test
this is my translation source: Eignungsprüfung (allgemein)
and this is the translated string from deepl: Aptitude test (general)
So the translation is correctly taken from the glossary, but the part after the space gets also translated.
So far my testing results, thank you for the explanation and the good work on this!
Comment #16
SteffenR@daveiano
This is not a bug of the module. The module only stores the subject/ definitions in drupal and pushes those entries into a deepl glossary.
While translating we only pass the glossary id, that should be used by the translation.
The replacement part is happening on the deepL site.
You may use the desktop app of deepL to check, how glossary entries get replaced. While using your example, you'll get the same result. The word (allgemein) is also getting translated unless it should be part of the glossary entry.
This issue could only be addressed by deepL.
Comment #17
mrshowermanThanks @SteffenR for working on this feature!
I had the same confusion as @daveiano in #15; does this mean that if Quick Checkout is enabled, no glossary will be used?
If that's the case, couldn't we auto-select one, especially if there's only one glossary available for the current language combination?
I was also wondering why there's no option to remove glossary entries. Is this due to API restrictions? It is possible to delete entries on DeepL's website, though.
Comment #18
SteffenR@mrshowerman
Right now the quick checkout (auto accept finished translations) won't support glossaries. But the suggestion you think ok could be integrated.
But we should think about having multiple glossary entities with the same target and source language for a translation job.
Which glossary should be used in this case?
Do we need any setting to enable/ disable the use of automatic glossary selection while quick checkout (auto-accept).
Editing / deleting of glossary entries is possible, since the module just uses a standard multiple field widget for editing the entries.
Deleting a single item in a multiple items field is another issue, but this is already being addressed in https://www.drupal.org/project/drupal/issues/1038316.
The API of deepL is "kind of limited" in its editing capabilities. You cannot edit existing glossaries directly, that's why, we delete/ recreate the glossary on "deepL side".
Comment #19
mrshowermanThanks for pointing out how to delete entries. I think this is a another good reason to fix that UI issue in #1038316: Allow for deletion of a single value of a multiple value field sooner than later, even experienced userstend to forget you simply have to empty the input field…
Concerning auto-selection of glossaries: I had been thinking about what to do in cases where more than one glossary matches, and the option to mark a glossary as default also came to my mind. But there can be cases where this still isn't unique, that's why I suggested to auto-select only when there's exactly one match.
Comment #20
vistree CreditAttribution: vistree commentedHi SteffenR - nice work!!! Is there any release plan? Is there a way to support with testing, ...?
Comment #21
SteffenR@vistree
We don't have a release plan for the feature, since most of the development is happening besides our main projects.
But the current MR can be tested.
Feel free to do so and add comments in this issue.
Short instructions for testing:
There is still need for some unit tests and polishing of error messages, but the main functionality is working.
I'll rebase against latest 2.1.x/ 2.2.x release, so don't be suprised about the commits in the next comment..
Comment #23
SteffenRComment #24
vistree CreditAttribution: vistree commentedHi SteffenR,
really nice work!! Thank you!!!
One question: we want to use deepl with glossaries in multiple project: is it somehow possible to uninstall the module without deleting the glossary on deepl backend? So, remove only in Drupal - but let it stay on deepl?
Comment #25
SteffenR@vistree
Currently this is not possible, because deleting a glossary would result in an API Call, which also deletes the glossary on deepL to keep things consistent.
If you have multiple sites, which should use the same glossary, you can run into some problems due to the API.
Since the glossary is directly tied to the deepL API token (free or paid), you can create one glossary per project and use it standalone.
Another approach for sharing multiple glossaries would be a "main site", were the glossaries can be edited/ administered for all projects. But for this approach the module needs some additional features like:
Comment #26
SteffenRI set this issue to "Needs review" to get some feedback from the community.
Please play around with the feature and leave comments in the issue for getting a 2.2.0 release.
Alpha release is available for testing.
Comment #28
DuaelFrI'll have to implement that in the next months. I'll provide feedback as soon as it's coming to my prioritary todo list.
Thank you for implementing that!
Comment #29
SteffenR@DuaelFr: I justed wanted to ask, if everything went fine, while implementing the feature?
Comment #30
mrshowerman@SteffenR, thanks very much once more for the great work on the glossary integration.
We started to use the new submodule, and it's working nicely. I was also suprised that we're now able to keep the "quick checkout" setting active, much appreciated!
I'd like to give feedback on one thing that came to my mind:
In order to enable editors to add, edit and delete glossary entries, it seems like not only the appropriate permissions are needed, but also the Administer DeepL glossary entities, otherwise they don't see the menu item. We might want to change this, so editors are able to edit glossary entries while not being permitted to edit the glossary entity itself.
Comment #31
SteffenRComment #32
SteffenR@mrshowerman: Further work on this topic should be covered within a new issue. May you check the Proposed resolution there and comment in case i'm missing sth..
Thx.
Comment #33
mrshowermanLeft a comment in the related issue.
I also noticed a few wording issues concerning the new glossary functionality. Since this issue is still in status Needs Review, should I leave comments here, or do you prefer a separate issue, @SteffenR?
Comment #34
SteffenRYep. Just leave a comment in here. I'll take care of those issues. Thx.
Comment #35
mrshowermanOk, here we go:
=> Duplicate "of". Same in line 151 of the same file, and also in modules/tmgmt_deepl_glossary/src/DeeplGlossaryApiBatchInterface.php (line 32) and modules/tmgmt_deepl_glossary/src/DeeplGlossaryApiInterface.php (line 57).
This text is hard to read. What about this:
=> Either remove the trailing dot, or add it to the other permission titles as well.
Should be
Same applies to lines 64 and 71.
Comment #36
SteffenRComment #44
SteffenR@mrshowerman Thx for the findings. I've changed the code according to your suggestions.
All occurences of deepL where changed to DeepL (like in their API documentation) and the description text was updated.
I also run a phpstan/ phpcs test against the tmgmt_deepl_glossary submodule and added some fixes.
The time was sponsored by my lovely daughter, who is currently at the swimming competition. (Dad taxi 🚕🚕🚕)
Comment #45
SteffenRComment #46
mrshowermanThanks a lot! Also to your lovely sponsor 🏊♀️🏊
Comment #47
SteffenRComment #50
SteffenR