wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
222 stars 84 forks source link

Add LibreTranslate machine translator, documentation and its test cases. #753

Closed drivard closed 8 months ago

drivard commented 8 months ago

This PR introduces a new machine translator to the wagtail-localize project, leveraging the LibreTranslate API. The LibreTranslator class extends the BaseMachineTranslator and implements the necessary methods for translation.

It supports configuration alike

WAGTAILLOCALIZE_MACHINE_TRANSLATOR = {
    "CLASS": "wagtail_localize.machine_translators.libretranslate.LibreTranslator",
    "OPTIONS": {
        "LIBRETRANSLATE_URL": "https://libretranslate.org",
        "API_KEY": "<Your LibreTranslate api key here>",
    },
}

The LibreTranslate API can also be hosted using many methods documented on their github page https://github.com/LibreTranslate/LibreTranslate. I tested it against a self-hosted instance.

Here are some screenshots of an about us page that I translated using the LibreTranslator.

image

image

Please review and provide any feedback.

codecov-commenter commented 8 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (a3efa8f) 92.60% compared to head (8d0d62b) 92.53%.

Files Patch % Lines
...ail_localize/machine_translators/libretranslate.py 76.47% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #753 +/- ## ========================================== - Coverage 92.60% 92.53% -0.07% ========================================== Files 46 47 +1 Lines 4017 4034 +17 Branches 598 600 +2 ========================================== + Hits 3720 3733 +13 - Misses 175 179 +4 Partials 122 122 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

drivard commented 8 months ago

@zerolab I have completed the changes requests. Please review.

drivard commented 8 months ago

@zerolab Do you have an idea of when it will be released ?

zerolab commented 8 months ago

Got a couple of more PRs and if all goes well, sometime next week (i.e before the end of the year)