-
Notifications
You must be signed in to change notification settings - Fork 91
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 free api #505
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you @vladox!
Did a quick first pass review with a minor suggestion.
The main thing here is we need a couple of tests (one for the setting and the other for the error message)
PR suggestion replaces if with get Co-authored-by: Dan Braghis <[email protected]>
That doesn't seem to apply for AUTH_KEY and seems too verbose for an
option. Since it can also be used in the future for other endpoints I'd
leave it as it is.
…On Tue, 15 Feb 2022 at 18:48, Dan Braghis ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In wagtail_localize/machine_translators/deepl.py
<#505 (comment)>
:
> @@ -17,8 +27,9 @@ class DeepLTranslator(BaseMachineTranslator):
display_name = "DeepL"
def translate(self, source_locale, target_locale, strings):
+ api_endpoint = self.options.get("API_ENDPOINT", "https://api.deepl.com/v2/translate")
nitpick: missed the first time around, but we do prefix our settings with
WAGTAILLOCALIZE_ so this should be consistent. i.e.
WAGTAILLOCALIZE_DEEPL_API_ENDPOINT
—
Reply to this email directly, view it on GitHub
<#505 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUGTDMVB76J7T7RQZIZH7DU3KGXJANCNFSM5MF5JKHQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@vladox sorry for the noise, I realised the options already came via |
} | ||
) | ||
def test_deepl_machine_translate_page(self): | ||
response = self.client.post( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but this will actually make and API request to the DEEPL endpoint. We should avoid this and instead mock the response
#604 provides a simpler approach to this, so may use that instead |
@vladox #604 conditionally loads the endpoint based on the key (deepl library reference) |
@zerolab there's also a part of the PR that handles exceptions from the API and shows them correctly formatted to the end user, see |
@vladoD you're right, let's do it. Just make sure you mock the request/response |
Essentially it enables the Deepl API to be changed since they have two different (free and pro).
Also some improvements were made on error handling:
There's a new option to define the Deepl API endpoint: