wagtail / wagtail-localize

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

Rich Text images' alt text is not being recognized by "extract_strings". #808

Open ho-tsl opened 4 months ago

ho-tsl commented 4 months ago

Hey there,

Currently, the extract_segments function does not recognize image alt texts inserted by a RichText block. This is an important accessibility issue that I would like your help to solve.

Is it possible to update the "extract_strings" function to extract these texts to be translated?

zerolab commented 4 months ago

Hey @ho-tsl,

Feel free to give it a try. The segment extraction happens in https://github.com/wagtail/wagtail-localize/blob/f5690d0d807b774d64dcd9a2975a26e01014ad52/wagtail_localize/segments/extract.py#L237 with the strings extraction in extract_strings as you point out.

It should be possible to do so. You may want to have a look at https://docs.wagtail.org/en/stable/extending/rich_text_internals.html#data-format for how Wagtail saves things like images/docs (and URLs) internally