Problem/Motivation
DeepL introduced an official PHP client library for the DeepL API a few month ago.
Our current approach is using the REST API directly and doesn't take advantage of the API client, which is really handy for developers.
Proposed resolution
- remove old REST API based code and switch to PHP client library while requesting translations
- add new deepl_api translator plugin, which deprecates the old deepl_pro and deepl_free translator plugins (no longer needed)
- rewrite tests to fit new approach - we no longer need to build custom endpoints and only create a mock for the requestTranslation / get Usage method of DeeplTranslator
Further information
- https://github.com/DeepLcom/deepl-php
- Example for mocking test classes https://paulund.co.uk/how-to-mock-classes-in-php
Issue fork tmgmt_deepl-3324073
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
steffenrComment #5
steffenrComment #9
steffenrComment #11
idebr commented@steffenr The merge request seems pretty complete. Is there anything that needs to be changed before a merge? The official PHP client would be very welcome when working on #3494249: Support translation of documents
Comment #12
steffenr@idebr
Actually i wanted to complete the test coverage of the code.
But at the moment I don't have the time to complete this, as writing the tests takes up more time.
From my point of view, it's possible to create a 2.3.x development release, that you can use as a starting point for your work on #3494249: Support translation of documents.
What do you think?
Comment #13
idebr commentedSure, that makes sense. Can completing the test coverage be done in a follow-up issue in 2.3.x?
Comment #14
steffenrYep - that's not a problem.
I just had the plan to build up a fully tested release. But as always it's about time ;)
Comment #16
steffenr