How can I internationalize additional fields on Wagtail's Image Model?

16 Views Asked by At

I have a CustomImage model as per standard implementation on my Wagtail project.

This model has extra fields caption and description:

class CustomImage(AbstractImage):
    caption = models.CharField(blank=True)
    description = models.TextField(blank=True)

    admin_form_fields = Image.admin_form_fields + ("caption","description")

wagtail i18n

I checked Wagtail's [docs for i18n]https://docs.wagtail.org/en/stable/advanced_topics/i18n.html) just in case, but the Wagtail default approach is more of a "clone a page into another language" which makes not much sense for pictures, since the whole idea is that you have one instance of a picture managed in the "Images" library, instead of multiple libraries.

wagtail-modeltranslation

Another solution would be to use wagtail-modeltranslation which is, at least for Pages, pretty much the right tool for the job. When I follow the normal integration steps, eventually I define the usual TranslationOptions:

@register(CustomImage)
class CustomImageOptions(TranslationOptions):
    fields = ["caption","description"]

which does lead the migrations to create the relevant fields in the database.

I'm guessing from a database standpoint this works, but wagtail-modeltranslation does not add the frontend-magic on the image model it seems: example of wagtail image edit window without translations

On the one hand, I understand that wagtail-modeltranslation is halfway there but I wonder if the fine folks at Torchbox have considered this problem before and maybe have another solution up their sleeves?

Or any other ideas?

Cheers

0

There are 0 best solutions below