Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translating Custom Image Models #794

Open
kaij opened this issue Mar 18, 2024 · 4 comments
Open

Translating Custom Image Models #794

kaij opened this issue Mar 18, 2024 · 4 comments

Comments

@kaij
Copy link

kaij commented Mar 18, 2024

Translating custom image models (see https://docs.wagtail.org/en/stable/advanced_topics/images/custom_image_model.html) is currently (Wagtail 6.x, Wagtail Localize 1.9-alpha) not possible. A common use case for custom image models are adding image credits (licenses, byline, description). It seems the only workaround for translatable custom images is adding a seperate model. However, this makes all the image pickers, image library etc. more or less useless and duplicates a lot of code.

What would be the tasks that need to implement translations for custom images?

@unreadableusername
Copy link

I think encountered the same issue testing compatibility of Wagtail 6 and Wagtail-Localize 1.9 with our existing code.
Translation of Strings worked as expected, but when trying to swap out an image or document based on a custom model as described in the Wagtail documentation the following Javascript error occurs:

Screenshot 2024-05-13 at 23 28 20

This is the code for our custom image model:

class CustomImage(AbstractImage):
    copyright = models.CharField(max_length=255)
    tags = TaggableManager(
        help_text=None, blank=True, verbose_name="tags", through=TaggedImage
    )
    admin_form_fields = Image.admin_form_fields + ("copyright",)


class CustomRendition(AbstractRendition):
    image = models.ForeignKey(
        CustomImage, on_delete=models.CASCADE, related_name="renditions"
    )

    class Meta:
        unique_together = (("image", "filter_spec", "focal_point_key"),)

@tognee
Copy link

tognee commented May 15, 2024

The same issue is present even when not using custom images.
I think it's linked with this: https://docs.wagtail.org/en/stable/releases/6.1.html#deprecation-of-window-chooserurls-within-draftail-choosers

@zerolab
Copy link
Collaborator

zerolab commented May 15, 2024

window.chooserUrls were only deprecated in 6.1, and will be removed in a future release, so I am not convinced.

Will have to have a look

@zerolab
Copy link
Collaborator

zerolab commented May 15, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants