wagtail / wagtail-localize

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

Default RawHTMLBlock not showing up if i want to translate it. #654

Closed pdeero closed 1 year ago

pdeero commented 1 year ago

Dear Community,

i have a page with a raw html block. If i translate the page then the raw html block will not be shown to translate it.

Path to the used block: venv/lib/python3.9/site-packages/wagtail/blocks/field_block.py

class RawHTMLBlock(FieldBlock):
    def __init__(
        self,
        required=True,
        help_text=None,
        max_length=None,
        min_length=None,
        validators=(),
        **kwargs,
    ):
        self.field = forms.CharField(
            required=required,
            help_text=help_text,
            max_length=max_length,
            min_length=min_length,
            validators=validators,
            widget=forms.Textarea,
        )
        super().__init__(**kwargs)

    def get_default(self):
        return mark_safe(self.meta.default or "")

    def to_python(self, value):
        return mark_safe(value)

    def get_prep_value(self, value):
        # explicitly convert to a plain string, just in case we're using some serialisation method
        # that doesn't cope with SafeString values correctly
        return str(value) + ""

    def value_for_form(self, value):
        # need to explicitly mark as unsafe, or it'll output unescaped HTML in the textarea
        return str(value) + ""

    def value_from_form(self, value):
        return mark_safe(value)

    class Meta:
        icon = "code"
Django==4.1.1
wagtail==4.1.1
wagtail_localize==1.3.2
django-extensions==3.2.0
psycopg2==2.9.3
loglevel==0.1.2
Wand==0.6.10
django-redis==5.2.0
sentry-sdk==1.10.1

Does someone can help or has an idea to fix it?

Thanks in advance.

Best Regards, Patrick

zerolab commented 1 year ago

@pdeero I see you closed this and #653, but no note as to why. Did you find a solution that worked for you? if so, others may be interested in the future, so please share. If not.. is it no longer relevant? Found another issue, thus this is a duplicate? etc

Would appreciate the input

pdeero commented 1 year ago

@zerolab sorry for the late reply and thanks your fast answer.

It doesn’t has worked cause i used a too old version of wagtail_localize.