-
Notifications
You must be signed in to change notification settings - Fork 573
Pretranslation API #3834
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
base: main
Are you sure you want to change the base?
Pretranslation API #3834
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
mathjazz
left a comment
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.
Nice work! Left some comments inline.
|
I also applied the same above env change for |
|
The code looks good! Why is the PR maked as Draft? Is there any functionality still missing? |
| if not locale: | ||
| errors["locale"] = ["This field is required."] |
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.
I wonder if we should also check if Locale.google_automl_model is set. That way Pretranslation API will only work for locales for which Pretranslation in Pontoon works, i.e. for the ones that have custom MT models.
@flodolo Thoughts?
|
You can test the PR on https://mozilla-pontoon-staging.herokuapp.com: import requests
response = requests.post(
"https://mozilla-pontoon-staging.herokuapp.com/api/v2/pretranslate/?locale=sl",
data="Open",
headers={
"Content-Type": "text/plain",
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
) |
|
Please add a flag in the |
Noting that this works on Heroku, but not on GCP (CSRF validation fails). |
|
This is the error displayed if we're missing the Google API keys. We probably need to fix this. |
Co-authored-by: Matjaž Horvat <matjaz.horvat@gmail.com>
d361bb7 to
5918bfc
Compare
Description
This PR implements a Pretranslation API at
api/v2/pretranslate/?format_string=FORMAT&locale=CODE. It utilizes existing pretranslation functionality in Pontoon and extends it as an authenticated service for those who need a pretranslation from either Translation Memory or AutoML.Fixes #3830.
Additional Notes
Authentication for this endpoint is temporarily disabled for easier testingRequires some testing onandroidandgettextresource formats.