andrewhancox / moodle-filter_translations

7 stars 8 forks source link

Images pasted into Atto editor break machine translation #157

Closed berthelemy closed 1 year ago

berthelemy commented 1 year ago

Background

Images pasted into Moodle's Atto editor, or imported from Word into the Book module, are converted to base64 before pasting into the HTML.

(See: https://moodle.org/mod/forum/discuss.php?d=280250)

We cannot stop our tutors from doing this, as it's such a common part of their workflow.

Problem

The base64 code is treated as translatable characters by Google Translate (GT). GT returns an error when there are too many characters to translate.

Every time GT returns an error, the content translation plugin backs off from translating for an hour or so, which means this issue will then affect many other pages.

The page with the base64 image will never translate.

Current workaround (not working as it's very intensive)

  1. Trawl the database for base64 images
  2. Find their location on the site
  3. Save the image as png
  4. Reupload the png

At the same time we've informed the tutors to not copy and paste images - although that is unlikely to work. It is even more difficult to train our students to do the same, when pasting an image is so much easier. We do not have a workaround for the Word -> Book import.

Possible solution

Before posting the string to GT, can we strip out any images encoded as base64?

andrewhancox commented 1 year ago

Resolved