Skip to content
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

Let machine translators skip fields #819

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tognee
Copy link

@tognee tognee commented Aug 27, 2024

Currently there is no way to keep a field not translated in case of issues with the machine translator.
Setting the value to an empty StringValue will show the field as translated in the admin.

This patch will let machine translators omit the key value pair to keep the field not translated.

(Sorry for the double PR, had issues with my linter)

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.02%. Comparing base (f465821) to head (5aa3c86).

Files with missing lines Patch % Lines
wagtail_localize/views/edit_translation.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #819      +/-   ##
==========================================
- Coverage   93.07%   93.02%   -0.05%     
==========================================
  Files          47       47              
  Lines        4144     4146       +2     
  Branches      704      705       +1     
==========================================
  Hits         3857     3857              
- Misses        173      174       +1     
- Partials      114      115       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zerolab
Copy link
Collaborator

zerolab commented Sep 3, 2024

Any chance you could add a test or two?

@tognee
Copy link
Author

tognee commented Sep 4, 2024

To add tests I would need to add a machine translator that could fail.
Can I edit the dummy translator so that it doesn't generate a response if the text to translate is more than 50 words, or should I add another machine translator just for the test?

@zerolab
Copy link
Collaborator

zerolab commented Sep 4, 2024

@tognee
Copy link
Author

tognee commented Sep 6, 2024

For my first implementation I would need to patch the translate method in the DummyTranslator class. I've extended the implementation to check if the StringValue data is null.

Added tests for both of them and it seems to be working.

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