wagtail / wagtail-localize

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

Prevent `TranslationCreator` create `Translation` objects with the same locale as the source locale` #749

Closed zerolab closed 8 months ago

zerolab commented 9 months ago

From an internal report where a site somehow ended up with multiple Translation objects where target_locale was the same as soruce.locale which the resulted in some odd behaviours.

Update https://github.com/wagtail/wagtail-localize/blob/main/wagtail_localize/operations.py#L63-L71 to skip any processing when target_locale == source.locale

ACK1D commented 8 months ago

Maybe this solution could help?

        for target_locale in self.target_locales:
            # Skip if target_locale is the same as source locale
            if target_locale == source.locale:
                continue
zerolab commented 8 months ago

Yep, that's pretty much the idea

zerolab commented 8 months ago

Fixed by #756